J.A.Cado J.A.Cado - 1 year ago 115
Python Question

Plotting multiple dataframes using pandas functionality

I have two dataframes, with unique x and y coordinates, and I want to plot them in the same figure.
I am now plotting two dataframes in same figure as such:


However, pandas also has plotting functionality.


How could I achieve the same as my first example but use the pandas functionality?

Answer Source


ax = df1.plot()

Basically pandas' plot function returns the matplotlib object, which you can then pass to the second dataframe.

Edit by J.A.Cado

I would like to add that I had to specify the x and y values for my code:

ax = df1.plot(x='Lat', y='Lon')
df2.plot(ax=ax, x='Lat', y='Lon')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download