6

The plot method of a GeoPandas GeoDataFrame overrides the DataFrame parent method to plot the geometries of the associated GeoSeries. This is very convenient, but I'd also like to use the easy ways Pandas provides to plot other properties of my dataset.

However, when I now try to make a scatterplot, or any other kind of plot, I get an error message:

mygeodataframe.plot(kind='scatter', x='somecolumn', 'y'='someothercolumn'...)
*** TypeError: plot_dataframe() got an unexpected keyword argument 'kind'

How do I get my plotting methods back? Converting a copy of the GeoDataFrame (minus the 'geometry' Series) into regular DataFrame helps, but it's clumsy.

I'm using GeoPandas version 0.1.1 and Pandas version 0.17.1.

7

The GeoPandas plotting methods are there for convenience. They do override the standard pandas plotting methods. For now, the easiest way to get access to basic pandas plotting is probably through their functional versions, something like this:

from pandas.tools.plotting import plot_frame
plot_frame(mygeodataframe, kind='scatter', ...)

Feel free to create an issue about this on the GitHub repository (or better yet, help implement a solution).

  • 2
    This works very well, thanks! Let me just add that an alternative I found is to specify the columns needed for the plot (mygeodataframe['somecolumn', 'someothercolumn'].plot(kind='scatter', x=...)). This does the trick for simple cases. I'll check out the project on GitHub. – chryss Mar 1 '16 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.