Comments (3)
When you assign a projection to the figure at large, geoplot
has no way of knowing where your "region of interest" will be once you start adding subplots. So you end up with...something.
If you calculate and pass the centroid as projection parameters:
square = shapely.geometry.Polygon([(41.5, 88), (41.75, 88), (41.75, 87.5), (41.5, 87.5)])
fig, ax = plt.subplots(1,1, subplot_kw={'projection': gplt.crs.AlbersEqualArea(central_latitude=87.75,
central_longitude=41.625)})
gplt.polyplot(gpd.GeoDataFrame({'geometry':square}, index=[1]), projection=gplt.crs.AlbersEqualArea(), ax=ax)
You get what you're looking for:
The examples always hardcode the projection centroid for this reason.
from geoplot.
Ah, I see. Thanks for sorting me out!
from geoplot.
For future reference for anyone coming across this issue that stumbles across the GH issue: geoplot
automatically determines the central latitude and/or central longitude of the projection you are using by taking the midpoint of the geopandas.GeoDataFrame.total_bounds
of your input data.
When you pass a projection to matplotlib
instead via plt.subplots
, geoplot
doesn't get to perform this intermediate step because the value is being set someplace else. You have to manually input the central coordinates for the projection yourself. For example:
proj = gcrs.AlbersEqualArea(central_longitude=-98, central_latitude=39.5)
f, axarr = plt.subplots(1, 2, figsize=(12, 4), subplot_kw={
'projection': proj
})
gplt.polyplot(contiguous_usa, projection=proj, ax=axarr[0])
gplt.polyplot(contiguous_usa, projection=proj, ax=axarr[1])
This is discussed in the documentation: Working with Projections#Projections on Subplots.
from geoplot.
Related Issues (20)
- Pin geopandas version? HOT 2
- cProfiling geoplot vs Cartopy vs GeoPandas: puzzling results HOT 2
- Typo in UserWarnings
- geoplot installed but geoplot.crs is not found HOT 4
- Legends in Geoplot 0.4.4 HOT 1
- Unable to install geoplot with pipenv under Ubuntu 20.04LTS HOT 1
- Grey boxes when clipping data with kdeplot HOT 8
- geoplot.kdeplot --> overlapping isolines HOT 8
- Fix KDEPlot hue tests HOT 6
- Voronoi plot fails with Value Error: Points cannot contain Nan HOT 4
- Does geoplot only work with EPSG:4326 unless the projection argument is set?
- Tests fail with geopandas 0.11
- Feature request? Apply pointplot "hue" to edgecolor only
- ModuleNotFoundError: No module named 'matplotlib.axes._subplots' HOT 1
- AttributeError: 'MultiPolygon' object has no attribute 'exterior' / TypeError: 'MultiPolygon' object is not iterable HOT 2
- kdeplot not working when fill=True HOT 2
- New Feature request - question: Bivariate choropleth?
- Exporting a KDEPlot as KML
- Documentation Update: shade is deprecated HOT 1
- Cannot import GeoPlot due to Iterable from collections
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geoplot.