has2k1 / plotnine

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

Add geom_map geometry for plotting geographic maps #14

Open adamboche opened 7 years ago

adamboche commented 7 years ago

ggplot2 has geom_map for plotting geography. I can imagine a nice interface with geopandas, which has gpd.GeoDataFrame.plot() through matplotlib. Here's a demo from the docs:

  ggplot(crimesm, aes(map_id = state)) +
    geom_map(aes(fill = value), map = states_map) +
    expand_limits(x = states_map$long, y = states_map$lat) +
    facet_wrap( ~ variable)

geom_map-8

has2k1 commented 7 years ago

I am working on a mapping geom (geom_carto), with geopandas and cartopy. Using cartopy as the backend though feature rich (real cartographic projections), is not straight-forward and there are changes I would want in cartopy.

I hoped to have it for the next minor release, though if I cannot tame cartopy in time, I may in the meanwhile create an alternative projection-less mapping geom just like geom_map.

liuzongquan commented 6 years ago

plotnine is so great! thanks to @has2k1 ~

jmccreight commented 6 years ago

+1

cwerner commented 6 years ago

Hi. New user here. Very excited about this project.

Is there any update on the geom_carto feature @has2k1 ? Also, is there any interest in also supporting gridded geodata (I'm thinking xarray: https://github.com/pydata/xarray)? I think this would be an awesome match!

has2k1 commented 6 years ago

@cwerner

geom_carto depends on cartopy acquiring a standard way to add artists, e.g. GeomCollection as suggested.

I have not looked into xarray, so my imagination on how to use it as a datasource it is blank.