【发布时间】:2018-08-08 07:33:55
【问题描述】:
我有一个数据框,其中日期为索引,浮点数为列,主要填充 NaN 和一些浮点数。
我正在绘制这个数据框:
fig, ax = plt.subplots()
plot(df2[11][2:], linestyle='dashed',linewidth=2,label='xx')
ax.set(xlabel='xx', ylabel='xx', title='xx')
ax.grid()
ax.legend()
绘图窗口打开,但没有出现数据。但是如果我使用标记而不是线,就会出现数据点。
我应该更正什么以将我的图表绘制为线?
编辑谢谢,它是这样工作的:
s1 = np.isfinite(df2[11][2:])
fig, ax = plt.subplots()
plot(df2.index[2:][s1],df2[11][2:].values[s1], linestyle='-',linewidth=2,label='xx')
ax.set(xlabel='xx', ylabel='xx',title='xx')
ax.grid()
ax.legend()
【问题讨论】:
标签: python pandas matplotlib