我试图复制嵌入到PyQt GUI中的this图表,但是我的代码有一个问题
N = 5
menMeans = (20, 35, 30, 35, 27)
womenMeans = (25, 32, 34, 20, 25)
menStd = (2, 3, 4, 1, 2)
womenStd = (3, 5, 2, 3, 3)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars: can also be len(x) sequence
p1 = self.axes.bar(ind, menMeans, width, color='#d62728', yerr=menStd)
p2 = self.axes.bar(ind, womenMeans, width,
bottom=menMeans, yerr=womenStd)
self.axes.set_ylabel('Scores')
self.axes.set_title('Scores by group and gender')
self.axes.set_xticks(ind)
self.axes.set_xticklabels(['G1', 'G2', 'G3', 'G4', 'G5'])
self.axes.set_yticklabels(np.arange(0, 81, 10))
self.axes.legend((p1[0], p2[0]), ('Men', 'Women'))
生产。在
G1不应该正好在原点,而是有点长。为此需要做些什么改变?在
链接到的示例适用于matplotlib 2.0版。但是您运行的是1.5或更低版本。因此您需要参考以前版本的示例:bar_stacked example表示1.5。 或者,可以将matplotlib更新到2.0版。在
另一种选择是使用^{} argument to ^{}
相关问题 更多 >
编程相关推荐