对于一个jupyter笔记本小部件,我尝试了以下方法:
with output:
fig, ax = plt.subplots(constrained_layout=True, figsize=(6, 4))
# move the toolbar to the bottom
fig.canvas.toolbar_position = 'bottom'
ax.grid(True)
line, = ax.plot(df.index, init_data, initial_color,)
ax.set_ylabel('CH4_HYD1')
ax.set_ylabel('')但是数据以一种奇怪的方式被绘制出来。隔离绘图方法并将其与pandas默认值进行比较时,pandas绘图将正确显示数据。
df['CH4_HYD1'].plot()熊猫图

plt.plot(['CH4_HYD1'])错误的情节?

我想使用轴图方法来生成具有多条不同特征的线的图。但我找不到可能非常简单的错误...这里的区别是什么?
发布于 2021-03-05 17:45:34
这是一个简短的示例,演示了如何使用matplotlib和pandas绘制DataFrame中的多行。本质上,pandas使用matplotlib来做绘图,所以它不应该有什么不同。

无论如何,我鼓励您研究一下seaborn。这是一个基于pandas和matplotlib的很棒的库,可以轻松地可视化数据帧。
https://stackoverflow.com/questions/66490025
复制相似问题