【发布时间】:2014-05-02 23:50:49
【问题描述】:
我需要为值绘制条形图:
male=('2', '1', '2', '6', '6', '1') # list may increase
time=('Tue_Aug_13_04:37:40_2013', 'Mon_Jul__1_02:33:11_2013','Tue_Aug_13_04:37:40_2013', 'Thu_Jul__4_01:53:32_2013', 'Mon_Jul__1_10:05:55_2013','Mon_Jul__1_04:15:25_2013')# list may increase
female=(16, 11, 16, 12, 12, 11) # list may increase
男绿女红如下图:
我试过的代码:
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Polygon
fig = plt.figure()
ax1 = fig.add_subplot(131)
ax1.bar(male, color='red', edgecolor='black')
ax1.bar(bottom=range(female), color='blue', edgecolor='black')
ax1.set_xticks(time)
plt.show()
为了绘制条形图,我需要进行哪些修改,如我的值所附图片所示?
【问题讨论】:
-
你想用
time做什么?你的x-axis 应该是什么? this question/answer 有帮助吗? -
嗨 Schorsch,时间应该在 x 轴和 y 轴上,因为男性和女性都以不同的颜色计数,并在其上显示计数。
标签: python-2.7 matplotlib