美文网首页python学习笔记
学习笔记----python绘图bar

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

作者: 三叠纪的小黑猫 | 来源:发表于2020-06-20 18:58 被阅读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)


相关文章

网友评论

    本文标题:学习笔记----python绘图bar

    本文链接:https://www.haomeiwen.com/subject/uiygxktx.html