Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pytest.param(gcrs.Orthographic(), marks=pytest.mark.xfail),
gcrs.Stereographic(),
pytest.param(gcrs.TransverseMercator(), marks=pytest.mark.xfail),
gcrs.LambertAzimuthalEqualArea(),
gcrs.WebMercator()
])
def test_subplots_global_projections(proj, countries):
gplt.polyplot(countries, proj, ax=plt.subplot(2, 1, 1, projection=proj)).set_global()
gplt.polyplot(countries, proj, ax=plt.subplot(2, 1, 2, projection=proj)).set_global()
return plt.gcf()
plot = Plot(self.nonempty_gdf, **{
**self.kwargs, **{'extent': (-1, -1, 1, 1), 'projection': gcrs.PlateCarree()}
})
xmin, xmax = plot.ax.get_xlim()
ymin, ymax = plot.ax.get_ylim()
assert xmin == -1
assert xmax == 1
assert ymin == -1
assert ymax == 1
# nonempty geometry, unsatisfiable extent case: warn and fall back to default
with pytest.warns(UserWarning):
# Orthographic can only show one half of the world at a time
Plot(self.nonempty_gdf, **{
**self.kwargs,
**{'extent': (-180, -90, 180, 90), 'projection': gcrs.Orthographic()}
})
gcrs.Orthographic(central_longitude=45, central_latitude=45),
gcrs.Stereographic(central_longitude=45, central_latitude=45),
pytest.param(
gcrs.TransverseMercator(central_longitude=45, central_latitude=45),
marks=pytest.mark.xfail
),
gcrs.LambertAzimuthalEqualArea(central_longitude=45, central_latitude=45),
])
def test_fully_parameterized_global_projections(proj, countries):
gplt.polyplot(countries, proj)
ax = plt.gca()
ax.set_global()
return plt.gcf()
gcrs.Orthographic(central_latitude=45),
gcrs.Stereographic(central_longitude=45),
gcrs.Stereographic(central_latitude=45),
pytest.param(gcrs.TransverseMercator(central_longitude=45), marks=pytest.mark.xfail),
pytest.param(gcrs.TransverseMercator(central_latitude=45), marks=pytest.mark.xfail),
pytest.param(gcrs.LambertAzimuthalEqualArea(central_longitude=45), marks=pytest.mark.xfail),
gcrs.LambertAzimuthalEqualArea(central_latitude=45),
])
def test_partially_parameterized_global_projections(proj, countries):
gplt.polyplot(countries, proj)
ax = plt.gca()
ax.set_global()
return plt.gcf()
For more information visit `the cartopy docs
`_.
"""
import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
import matplotlib.pyplot as plt
import cartopy
la_flights = gpd.read_file(gplt.datasets.get_path('la_flights'))
f, axarr = plt.subplots(2, 2, figsize=(12, 12), subplot_kw={
'projection': gcrs.Orthographic(central_latitude=40.7128, central_longitude=-74.0059)
})
plt.suptitle('Popular Flights out of Los Angeles, 2016', fontsize=16)
plt.subplots_adjust(top=0.95)
ax = gplt.sankey(
la_flights, scale='Passengers', hue='Passengers', cmap='Purples', k=5, ax=axarr[0][0]
)
ax.set_global()
ax.outline_patch.set_visible(True)
ax.coastlines()
ax = gplt.sankey(
la_flights, scale='Passengers', hue='Passengers', cmap='Purples', k=5, ax=axarr[0][1]
)
ax.set_global()
ax.outline_patch.set_visible(True)
For more information visit `the cartopy docs
`_.
"""
import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
import matplotlib.pyplot as plt
import cartopy
la_flights = gpd.read_file(gplt.datasets.get_path('la_flights'))
f, axarr = plt.subplots(2, 2, figsize=(12, 12), subplot_kw={
'projection': gcrs.Orthographic(central_latitude=40.7128, central_longitude=-74.0059)
})
plt.suptitle('Popular Flights out of Los Angeles, 2016', fontsize=16)
plt.subplots_adjust(top=0.95)
ax = gplt.sankey(
la_flights, scale='Passengers', hue='Passengers', cmap='Purples', ax=axarr[0][0]
)
ax.set_global()
ax.outline_patch.set_visible(True)
ax.coastlines()
ax = gplt.sankey(
la_flights, scale='Passengers', hue='Passengers', cmap='Purples', ax=axarr[0][1]
)
ax.set_global()
ax.outline_patch.set_visible(True)
###############################################################################
# Plotting with Geoplot
# =====================
#
# We start out by replicating the basic GeoPandas world plot using Geoplot.
geoplot.polyplot(world, figsize=(8, 4))
###############################################################################
# Geoplot can re-project data into any of the map projections provided by
# CartoPy (see the list
# `here `_).
# use the Orthographic map projection (e.g. a world globe)
ax = geoplot.polyplot(
world, projection=geoplot.crs.Orthographic(), figsize=(8, 4)
)
ax.outline_patch.set_visible(True)
###############################################################################
# ``polyplot`` is trivial and can only plot the geometries you pass to it. If
# you want to use color as a visual variable, specify a ``choropleth``. Here
# we sort GDP per person by country into five buckets by color, using
# "quantiles" binning from the `Mapclassify `_
# library.
import mapclassify
gpd_per_person = world['gdp_md_est'] / world['pop_est']
scheme = mapclassify.Quantiles(gpd_per_person, k=5)
# Note: this code sample requires geoplot>=0.4.0.
geoplot.choropleth(