我有两个数据帧,具有唯一的x和y坐标,我想将它们绘制在同一张图中。我现在用相同的图形绘制两个数据帧:
plt.plot(df1['x'],df1['y'])
plt.plot(df2['x'],df2['y'])
plt.show但是,pandas还具有绘图功能。
df.plot()我如何使用pandas功能来实现与第一个示例相同的功能?
发布于 2016-05-24 20:53:30
将索引中的所有列绘制为折线图。
ax = df1.plot()
df2.plot(ax=ax)信号pandas.DataFrame.plot (而不是subplots=True)返回一个matplotlib.axes.Axes,然后可以将其传递给第二个数据帧。
将特定列绘制为x和y。散点图(kind='scatter')需要指定x和y。
ax = df1.plot(x='Lat', y='Lon', figsize=(8, 8))
df2.plot(ax=ax, x='Lat', y='Lon')https://stackoverflow.com/questions/37414008
复制相似问题