has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
3.89k stars 209 forks source link

Include geodatasets example in geom_map reference page #794

Open machow opened 1 month ago

machow commented 1 month ago

Around the end of 2023, it looks like a nice package called geodatasets was released, and is used throughout geopandas tutorials (e.g. this one).

It could be helpful to have an example in geom_map that uses geodatasets. This way, people can use the same data as in geopandas tutorials, and get started quickly with fetching shapefiles.

Here's a plot I made based off the geopandas tutorial, which was helpful to see:

import geopandas as gp
import geodatasets

chicago = gp.read_file(geodatasets.get_path("geoda.chicago_commpop"))
groceries = gp.read_file(geodatasets.get_path("geoda.groceries"))

(
    ggplot()
    + geom_map(data=chicago, fill=None)
    + geom_map(data=groceries.to_crs(chicago.crs), color="green")
    + theme_void()
    + coord_fixed()
)
image
(
    ggplot(chicago, aes(fill="POP2010"))
    + geom_map() 
    + coord_fixed()
    + scale_fill_cmap('plasma')
)
image