Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_choropleth(self):
try:
gplt.choropleth(series_gaussian_polys, hue=list_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=list_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=list_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=series_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=map_hue_values())
gplt.choropleth(dataframe_gaussian_polys, hue='hue_var')
finally:
plt.close('all')
def test_choropleth(self, projection,
hue_vars,
legend_vars):
kwargs = {'projection': projection}
kwargs = {**kwargs, **hue_vars, **legend_vars}
try: gplt.choropleth(gaussian_polys, **kwargs)
finally: plt.close()
def test_choropleth(self):
try:
gplt.choropleth(series_gaussian_polys, hue=list_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=list_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=list_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=series_hue_values)
gplt.choropleth(dataframe_gaussian_polys, hue=map_hue_values())
gplt.choropleth(dataframe_gaussian_polys, hue='hue_var')
finally:
plt.close('all')
def plot_state_to_ax(state, ax):
gplt.choropleth(
tickets.set_index('id').loc[:, [state, 'geometry']],
hue=state, cmap='Blues',
linewidth=0.0, ax=ax
)
gplt.polyplot(
nyc_boroughs, edgecolor='black', linewidth=0.5, ax=ax
)
def plot_state_to_ax(state, ax):
gplt.choropleth(
tickets.set_index('id').loc[:, [state, 'geometry']],
hue=state, cmap='Blues',
linewidth=0.0, ax=ax
)
gplt.polyplot(
nyc_boroughs, edgecolor='black', linewidth=0.5, ax=ax
)
"white" in the 2000 census. New York City is far more ethnically diversity than the rest of the
state.
"""
import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
import matplotlib.pyplot as plt
ny_census_tracts = gpd.read_file(gplt.datasets.get_path('ny_census'))
ny_census_tracts = ny_census_tracts.assign(
percent_white=ny_census_tracts['WHITE'] / ny_census_tracts['POP2000']
)
gplt.choropleth(
ny_census_tracts,
hue='percent_white',
cmap='Purples', linewidth=0.5,
edgecolor='white',
legend=True,
projection=gcrs.AlbersEqualArea()
)
plt.title("Percentage White Residents, 2000")
plt.savefig("ny-state-demographics.png", bbox_inches='tight', pad_inches=0.1)
)
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(
world, hue=gpd_per_person, scheme=scheme,
cmap='Greens', figsize=(8, 4)
)
###############################################################################
# If you want to use size as a visual variable, use a ``cartogram``. Here are
# population estimates for countries in Africa.
africa = world.query('continent == "Africa"')
ax = geoplot.cartogram(
africa, scale='pop_est', limits=(0.2, 1),
edgecolor='None', figsize=(7, 8)
)
geoplot.polyplot(africa, edgecolor='gray', ax=ax)
###############################################################################