Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
Problem
While working with geospatial datasets and plotting choropleth maps using GeoPandas and Matplotlib, I found that Matplotlib lacks high-level support for customizing individual geographic regions like countries or states.
For example, with this code:
# Defining the colour mapcmap='YlOrRd'# Plotting the choropleth map with the specified colour mapgdfplot2.plot(column='2010',cmap=cmap,legend=True,figsize=(45,20))# Adding a title to the plotplt.title('Greenhouse Gas Emissions by Country (2010)',fontsize=30)
Problem
This works well for basic plotting, but there is no intuitive or straightforward way to:
- Highlight or isolate individual countries programmatically
- Customize boundaries (e.g., thickness, color) per region
- Handle interactivity or advanced legends for geographic features
- Perform operations like region grouping or filtering directly through plotting
Suggested Improvements
It would be helpful if Matplotlib could:
- Provide built-in support (or helper APIs) to handle shapefiles/GeoJSONs at a per-region level
- Allow more granular styling of geographic entities
- Improve legend handling specific to choropleth or map-based plots
- Improve compatibility and documentation for geographic plotting workflows with GeoPandas
Alternatives Tried
- GeoPandas + Matplotlib (current approach): Limited for advanced control
- Cartopy: More powerful, but complex and not as easy to integrate for basic choropleths
- Plotly and Folium: Great for interactivity, but lack the publication-quality static rendering of Matplotlib
Summary
I believe a more seamless API or tighter integration for geospatial plotting would benefit many users who want both the power of Matplotlib and finer control over geographic data visualizations.
Please let me know if I have missed any built-in functionality or best practices. I'm happy to explore or contribute if pointed in the right direction.
Proposed solution
Helper APIS: Introduce built-in helper functions in Matplotlib to facilitate easier manipulation and styling of individual geographic regions (e.g., specifying boundaries, isolating regions).
Granular Styling: Extend the plotting functionality to allow advanced customisation for choropleths, like region-specific boundary thickness, colour, or style (possibly via additional arguments in the plot() method).
Legend Handling: Implement a more intuitive approach for creating and customising legends for choropleth maps, including custom ranges, labels, or multiple colour scales.