How to use the geoplot.choropleth function in geoplot

To help you get started, we’ve selected a few geoplot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ResidentMario / geoplot / tests / input_tests.py View on Github external
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')
github ResidentMario / geoplot / tests / property_tests.py View on Github external
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()
github ResidentMario / geoplot / tests / input_tests.py View on Github external
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')
github ResidentMario / geoplot / docs / gallery / plot_nyc_parking_tickets.py View on Github external
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
    )
github ResidentMario / geoplot / _downloads / 3dcded7153c2dd631cf592a948363b12 / plot_nyc_parking_tickets.py View on Github external
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
    )
github ResidentMario / geoplot / _downloads / 9c9ecca147d521f1f706cd62c090584f / plot_ny_state_demographics.py View on Github external
"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)
github geopandas / geopandas / examples / plotting_with_geoplot.py View on Github external
)
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)

###############################################################################