python 并列条形图_python – 如何绘制具有相同X坐标并排的条形图
在matplotlib站點(diǎn)有一個(gè)
example.基本上,你只是按照寬度移動(dòng)x值.這里是相關(guān)的位:
import numpy as np
import matplotlib.pyplot as plt
N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
# add some
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind+width)
ax.set_xticklabels( ('G1', 'G2', 'G3', 'G4', 'G5') )
ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
plt.show()
總結(jié)
以上是生活随笔為你收集整理的python 并列条形图_python – 如何绘制具有相同X坐标并排的条形图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: groovy java_Java 、Gr
- 下一篇: java idea 模块_使用Intel