python 折线图x时间_如何使用Python中的pyplot绘制日期与值的折线图?

我在绘制简单的折线图时遇到了问题,在y轴上有数值,其中轴上的日期是:

我的python代码如下:i = 0 #iterator for weather data

xAxis = []

yAxis = []

for trainingDate in observations[:,0]: #getting values in x and y axis for the desired chart

while weatherAttribute[0][i] != trainingDate:

xAxis.append(trainingDate)

yAxis.append(weatherAttribute[1][i])

i = i + 1

i = 0

fig=plt.figure()

graph = fig.add_subplot(111)

i = 0

for xdate in xAxis: #format of xdate is '2007-05-29'

graph.plot(DT(xdate).strftime("%Y-%b-%d"), yAxis[i])

i = i + 1

plt.show()

weatherAttribute列表存储日期和值,其中as observations list只有日期。在两个列表的匹配日期上,我希望在图表上显示weatherAttribute列表的相应值。简而言之,期望的图表应该在x轴上有日期,在y轴上有数值。在

但我在这方面面临着错误:

^{pr2}$

错误信息是:TypeError: 'module' object is not callable

我的进口是:import datetime as DT

from matplotlib import pyplot as plt

我相信这是一个简单的问题,但我已经查过了,不能解决。我很抱歉,因为我是Python的初学者。感谢您抽出时间等待建议!在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值