我需要用水平堆积条形图绘制一些图表。在
我有一些日期时间数据,这个数据等于测试的startTime(看起来startTime应该是'left'参数皮拉布·巴尔,例如left=startTime) 在x轴下应该写上日期,每个日期都应该等于24小时在图片上你可以看到,这个应该是怎样的,每个测试都应该在正确的日期勾选:
startTime = [datetime.datetime(2015,3, 4, 23, 4, 17),
datetime.datetime(2015,3, 5, 23, 4, 17),
datetime.datetime(2015,3, 6, 23, 4, 17)]
我有以秒为单位的测试持续时间(如果需要,我也可以将秒转换为datetime);持续时间将是每个条的长度。在
^{pr2}$我的代码看起来是这样,但我不知道如何将left参数设置为datetime
,也不知道如何使用小时数将xTicks
设置为datetime
:
dynamicNlocator = 24
fig, ax1 = plt.subplots(figsize=(15, 8)) # height and width of chart
plt.subplots_adjust(left=0.120, right=0.98)
fig.canvas.set_window_title(u'Eldorado K-8 Fitness Chart')
pos = np.arange(numCp)+0.5 # Center bars on the Y-axis ticks
rects = pylab.barh(pos, testDuration, align=u'center', left=startTime, height=0.5, color=u'm', label=u"Actual start Time")
box = ax1.get_position()
ax1.set_position([box.x0, box.y0 + box.height * 0.1,
box.width, box.height * 0.9])
ax1.legend(loc='upper center', bbox_to_anchor=(0.5, -0.08),
fancybox=True, shadow=True, ncol=4)
ax1.axis([0, 100, 0, numTest])
pylab.yticks(pos, testName, size=13)
ax2 = ax1.twinx()
ax2.xaxis.set_major_locator(MaxNLocator(dynamicNlocator))
现在我无法将所需的测试移到正确的日期,图表应该如下所示:
目前没有回答
相关问题 更多 >
编程相关推荐