Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom color for each polygon #387

Closed
willhaslam opened this issue Jan 10, 2017 · 2 comments

Comments

@willhaslam
Copy link

@willhaslam willhaslam commented Jan 10, 2017

No description provided.

@willhaslam

This comment has been minimized.

Copy link
Author

@willhaslam willhaslam commented Jan 10, 2017

After spending all day on this I figured it out I could just loop through my categories and set the facevalue and plot them that way

@willhaslam willhaslam closed this Jan 10, 2017
@jorisvandenbossche

This comment has been minimized.

Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Jan 11, 2017

@willhaslam With geopandas master, you can actually use the plot_polygon_collection function (which is used by the .plot() method on a GeoDataFrame under the hood). Something like this then works:

from geopandas.plotting import plot_polygon_collection

fig, ax = plt.subplots()
ax.set_aspect('equal')
plot_polygon_collection(ax, gdf['geometry'], gdf['colors'], plot_values=False)

Small example with this: http://nbviewer.jupyter.org/gist/jorisvandenbossche/57d392c085901eb4981054402b37b6b1

I think this is a nice example of when using the lower-level plotting functions in geopandas can be useful.
In principle it is also possible to add support for this in the GeoDataFrame.plot(..) method when you supply a list-like to colors=.. that has the same length as the number of values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.