即使df包含0或NaN,堆积面积图显示

时间:2018-10-22 13:17:37

标签: python pandas matplotlib

我正在使用df.plot.area(),并对结果感到非常困惑。数据框具有整数作为索引。要绘制的值在不同的列中。一列包含从特定整数开始的零,但是我仍然可以在图中看到一条不正确的细线。

数据处理后,这是我实际绘制的代码:

# Start plotting
df.plot(kind='area', stacked=True, color=colors)
plt.legend(loc='best')
plt.xlabel('Year', fontsize=12)
plt.ylabel(mylabel, fontsize=12)

# Reverse Legend
ax = plt.gca()
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles[::-1], labels[::-1])

plt.title(filename[:-4])
plt.tight_layout()
plt.autoscale(enable=True, axis='x', tight=True)

这是结果的snapshot,橙色细线不可见,因为数据框中的值为零。

感谢您的支持!

0 个答案:

没有答案
相关问题