bar plot

import matplotlib.pyplot as plt
import seaborn as sns

# 创建图形和子图
fig, axes = plt.subplots(1, 2, figsize=(16, 6))

# 第一个子图 - ISOP排放
ax1 = axes[0]

bvoc_2022 = 199003.21160612212
bvoc_past_3_years = 182965.19822674562

# 柱状图设置
labels = ['2022', '2019-2021']
values = [bvoc_2022 / 1000, bvoc_past_3_years / 1000]

# 绘制柱状图
sns.barplot(x=labels, y=values, palette=[ '#00B386','#B0EFD9'], saturation=0.8, width=0.4, ax=ax1)

ax1.set_ylim(150, 220)
ax1.set_xlim(-0.5, 1.5)  # 设置x轴范围,使得两个柱子之间有一定间距
ax1.set_ylabel('ISOP emission (*10^8 kg)', fontsize=24)
ax1.tick_params(labelsize=24)
ax1.text(0.05, 0.95, '(a)', transform=ax1.transAxes, fontsize=23, va='top', ha='left')
# 第二个子图 - Net O3 production rate
ax2 = axes[1]

# 数据准备
time = np.arange(0, 24)
isop = np.array(df.isoprene)
hcho = np.array(df.HCHO)
total = isop + hcho

# 绘制柱状图
ax2.bar(time, isop, label='B_ISOP', alpha=0.7, color='#00B386')
ax2.bar(time, hcho, bottom=isop, label='B_HCHO', alpha=0.7, color='#B0EFD9')
ax2.bar(time, base-isop-hcho, bottom=isop+hcho, label='AVOC', alpha=0.7, color='orangered')#color=color_palette[2])
ax2.plot(time, total, color='green', label='Total BVOC')
ax2.set_xlabel('Hour', fontsize=22)
ax2.set_ylabel('Net O$_3$ production rate\n(ppbv h$^{-1}$)', fontsize=22, multialignment='center')
ax2.tick_params(axis='both', which='major', labelsize=22)
ax2.legend(fontsize=16)
ax2.text(0.05, 0.95, '(b)', transform=ax2.transAxes, fontsize=23, va='top', ha='left')
# 调整子图之间的间距
plt.subplots_adjust(wspace=0.4)
plt.savefig('./box_bvoc.png',dpi=450,bbox_inches='tight')
# 显示图形
plt.show()

image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容