Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyQt和MatPlotLib-嵌入式条形图从原点开始_Python_User Interface_Matplotlib_Pyqt4_Bar Chart - Fatal编程技术网

Python PyQt和MatPlotLib-嵌入式条形图从原点开始

Python PyQt和MatPlotLib-嵌入式条形图从原点开始,python,user-interface,matplotlib,pyqt4,bar-chart,Python,User Interface,Matplotlib,Pyqt4,Bar Chart,我试图重现嵌入PyQt GUI中的图表,但我的代码有一个问题 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 ba

我试图重现嵌入PyQt GUI中的图表,但我的代码有一个问题

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或更低。因此,您需要参考以前版本的示例:对于1.5。 或者,可以将matplotlib更新为2.0版

另一种选择是使用

plt.bar(... , align="center")