python学习笔记

学习笔记----python绘图bar

2020-06-20  本文已影响0人  三叠纪的小黑猫

# python 绘制柱状图并保存PNG


import matplotlib.pyplot as plt

from matplotlib.pyplot import MultipleLocator

x = [1, 2, 3]

a = [1129, 973, 932]

b = [31, 107, 138]

labels = ['2017SEG', '2018SEG', '2019SEG']

plt.bar(x, a, 0.3, tick_label=labels)

plt.bar(x, b, 0.3, bottom=a, label='ML Paper')

plt.xticks(fontsize=15)

plt.yticks(fontsize=15)

font = {'size':15}

legend = plt.legend(prop=font)

#plt.show()

fig = plt.gcf()

fig.set_size_inches(18.5, 4.5)

fig.savefig('test.png', dpi=100)


上一篇下一篇

猜你喜欢

热点阅读