0

I would like to draw graphs like this (Sorry, I was not able to upload the picture) http://www.organizationview.com/wp-content/uploads/2011/01/Stacked-distribution.jpg

Which software can do this? Is there any python utilities that can do this?

4

3 回答 3

1

我给你做了一个工作 matplotlib 例子。每个条形图我只制作了三个组件。在您的示例中为五个总数添加两个作为练习留给读者。:) 下面引用了代码。你也可以现场观看或下载我的 IPython notebook: http: //nbviewer.ipython.org/5852773

import numpy as np
import matplotlib.pyplot as plt

width=0.5

strong_dis = np.array((20, 10, 5, 10, 15))
disagree = np.array((20, 25, 15, 15, 10))
# shortcut here
therest = np.subtract(100, strong_dis + disagree)

q = np.arange(5)

bsd=plt.barh(q, strong_dis, width, color='red')
bd=plt.barh(q, disagree, width, left=strong_dis, color='pink')
br=plt.barh(q, therest, width, left=strong_dis+disagree, color='lightblue')

ylabels = tuple(reversed(['A', 'B', 'C', 'D', 'E']))
plt.yticks(q+width/2., ylabels)

plt.xlabel('Responses (%)')
plt.legend((bsd, bd, br), ('strong disagree', 'disagree', 'the rest'))
plt.show()
于 2013-06-24T19:24:19.820 回答
0

matplotlib 库可用于在 Python 中生成图形。 http://matplotlib.org/

于 2013-06-24T19:04:14.367 回答
0

看看matplotlib。他们有一个示例部分,其中包括一个堆积条形图

于 2013-06-24T19:04:46.103 回答