并列柱形图的绘制
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['font.sans-serif']=['Times New Roman']
plt.rcParams['axes.unicode_minus'] = False
fig = plt.figure(figsize=(100, 30),dpi=50)
for i,name in enumerate(['拖网','围网','刺网','张网','钓业']):
data_S = data[data['作业类型'] == name].copy()
ax = fig.add_subplot(1,5,i+1)
ax.spines['bottom'].set_linewidth('1.0')
ax.spines['bottom'].set_color('black')
ax.spines['top'].set_linewidth('1.0')
ax.spines['top'].set_color('black')
ax.spines['right'].set_linewidth('1.0')
ax.spines['right'].set_color('black')
ax.spines['left'].set_linewidth('1.0')
ax.spines['left'].set_color('black')
plt.xticks(fontsize = 20)
plt.yticks(fontsize = 20)
mincolor=(42/256,87/256,141/256,0/3)
midcolor=(42/256,87/256,141/256,0/3)
index=numpy.arange(len(data_S))
plt.bar(
index,
data_S['Initial carbon quantity(Ton)'],
color=mincolor,edgecolor='black',
width=1/3,label = 'Initial carbon quantity(Ton)',hatch='/\\')
plt.bar(
index+1/3,
data_S['Adjusted carbon quantity(Ton)'],
color=midcolor,edgecolor='black',
width=1/3,label = 'Adjusted carbon quantity(Ton)',hatch='//')
plt.xticks(index+1/6,data_S['name_english'])
plt.xticks(size=45,rotation = 40)
plt.yticks(size=40)
plt.title(data_S.iloc[0,-2],size=50)
lines, labels = fig.axes[-1].get_legend_handles_labels()
fig.legend(lines, labels,loc='upper center', bbox_to_anchor=(0.5, 0.05), ncol=3,fontsize = 50)
plt.savefig('论文使用——英文.png',dpi = 300,pad_inches=0.1)