Giter VIP home page Giter VIP logo

Comments (3)

ResidentMario avatar ResidentMario commented on June 1, 2024

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:

image

The examples always hardcode the projection centroid for this reason.

from geoplot.

hinnefe2 avatar hinnefe2 commented on June 1, 2024

Ah, I see. Thanks for sorting me out!

from geoplot.

ResidentMario avatar ResidentMario commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.