How to use the geoplot.kdeplot 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_kdeplot(self):
        try:
            gplt.kdeplot(series_gaussian_points)
            gplt.kdeplot(dataframe_gaussian_points)

            gplt.kdeplot(dataframe_gaussian_points, hue=list_hue_values)
            gplt.kdeplot(dataframe_gaussian_points, hue=series_hue_values)
            gplt.kdeplot(dataframe_gaussian_points, hue=map_hue_values)
            gplt.kdeplot(dataframe_gaussian_points, hue='hue_var')
        finally:
            plt.close('all')
github ResidentMario / geoplot / tests / viz_tests.py View on Github external
    pytest.param(*[kdeplot, p_df, {'projection': AlbersEqualArea()}], marks=pytest.mark.xfail),
    [polyplot, poly_df, {}],
    [polyplot, poly_df, {'projection': AlbersEqualArea()}],
    # xfail because webmap tiles are subject to remote change
    pytest.param(*[webmap, p_df, {'projection': WebMercator()}], marks=pytest.mark.xfail),
    [choropleth, poly_df, {'hue': 'var', 'linewidth': 0, 'legend': True}],
    [choropleth, poly_df, 
     {'hue': 'var', 'linewidth': 0, 'legend': True,
      'projection': AlbersEqualArea()}],
    [cartogram, poly_df, {'scale': 'var', 'linewidth': 0, 'legend': True}],
    [cartogram, poly_df,
     {'scale': 'var', 'linewidth': 0, 'legend': True,
      'projection': AlbersEqualArea()}],
    [voronoi, p_df, {'facecolor': 'lightgray', 'edgecolor': 'white'}],
    [voronoi, p_df, 
     {'facecolor': 'lightgray', 'edgecolor': 'white',
      'projection': AlbersEqualArea()}],
github ResidentMario / geoplot / tests / viz_tests.py View on Github external
def test_clip_params_overlay(kwargs):
    return kdeplot(p_df, **kwargs).get_figure()
github ResidentMario / geoplot / tests / viz_tests.py View on Github external
def test_hue_params_kdeplot(kwargs):
    return kdeplot(p_df, **kwargs).get_figure()
github ResidentMario / geoplot / tests / input_tests.py View on Github external
def test_kdeplot(self):
        try:
            gplt.kdeplot(series_gaussian_points)
            gplt.kdeplot(dataframe_gaussian_points)

            gplt.kdeplot(dataframe_gaussian_points, hue=list_hue_values)
            gplt.kdeplot(dataframe_gaussian_points, hue=series_hue_values)
            gplt.kdeplot(dataframe_gaussian_points, hue=map_hue_values)
            gplt.kdeplot(dataframe_gaussian_points, hue='hue_var')
        finally:
            plt.close('all')
github geopandas / geopandas / examples / plotting_with_geoplot.py View on Github external
###############################################################################
# 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)

###############################################################################
# If we have data in the shape of points in space, we may generate a
# three-dimensional heatmap on it using ``kdeplot``.

ax = geoplot.kdeplot(
    collisions.head(1000), clip=boroughs.geometry,
    shade=True, cmap='Reds',
    projection=geoplot.crs.AlbersEqualArea())
geoplot.polyplot(boroughs, ax=ax, zorder=1)

###############################################################################
# Alternatively, we may partition the space into neighborhoods automatically,
# using Voronoi tessellation. This is a good way of visually verifying whether
# or not a certain data column is spatially correlated.

ax = geoplot.voronoi(
    collisions.head(1000), projection=geoplot.crs.AlbersEqualArea(),
    clip=boroughs.simplify(0.001),
    hue='NUMBER OF PERSONS INJURED', cmap='Reds',
    legend=True,
    edgecolor='white'
github ResidentMario / geoplot / examples / plot_nyc_collision_factors.py View on Github external
import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
import matplotlib.pyplot as plt

nyc_boroughs = gpd.read_file(gplt.datasets.get_path('nyc_boroughs'))
nyc_collision_factors = gpd.read_file(gplt.datasets.get_path('nyc_collision_factors'))


proj = gcrs.AlbersEqualArea(central_latitude=40.7128, central_longitude=-74.0059)
fig = plt.figure(figsize=(10,5))
ax1 = plt.subplot(121, projection=proj)
ax2 = plt.subplot(122, projection=proj)

gplt.kdeplot(
    nyc_collision_factors[
        nyc_collision_factors['CONTRIBUTING FACTOR VEHICLE 1'] == "Failure to Yield Right-of-Way"
    ],
    cmap='Reds',
    projection=proj,
    shade=True, shade_lowest=False, 
    clip=nyc_boroughs.geometry,
    ax=ax1
)
gplt.polyplot(nyc_boroughs, zorder=1, ax=ax1)
ax1.set_title("Failure to Yield Right-of-Way Crashes, 2016")

gplt.kdeplot(
    nyc_collision_factors[
        nyc_collision_factors['CONTRIBUTING FACTOR VEHICLE 1'] == "Lost Consciousness"
    ],
github ResidentMario / geoplot / _downloads / 600d8a8b8575df48f2e217113a87b09f / plot_boston_airbnb_kde.py View on Github external
``mplleaflet`` library. We sample just 1000 points, which captures the overall trend without
overwhelming the renderer.

`Click here to see this plot as an interactive webmap. 
`_
"""

import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
import matplotlib.pyplot as plt
import mplleaflet

boston_airbnb_listings = gpd.read_file(gplt.datasets.get_path('boston_airbnb_listings'))

ax = gplt.kdeplot(
    boston_airbnb_listings, cmap='viridis', projection=gcrs.WebMercator(), figsize=(12, 12),
    shade=True
)
gplt.pointplot(boston_airbnb_listings, s=1, color='black', ax=ax)
gplt.webmap(boston_airbnb_listings, ax=ax)
plt.title('Boston AirBnB Locations, 2016', fontsize=18)

fig = plt.gcf()
plt.savefig("boston-airbnb-kde.png", bbox_inches='tight', pad_inches=0.1)
# mplleaflet.show(fig)
github ResidentMario / geoplot / docs / examples / boston-airbnb-kde.py View on Github external
import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs
import matplotlib.pyplot as plt
import mplleaflet

# load the data
boston_airbnb_listings = gpd.read_file(gplt.datasets.get_path('boston_airbnb_listings'))

# we're building a webmap, so we'll first create an unprojected map.
ax = gplt.kdeplot(boston_airbnb_listings)

# Now we'll output this map to mplleaflet to generate our webmap. In this example we'll actually go one step further,
# and use a non-default tile layer as well. The default mplleaflet webmap uses the default Leaflet tile service,
# which is Open Street Map (OSM). OSM works great in a lot of cases, but tends to be very busy at a local level (an
# actual strategic choice on the part of the OSM developers, as the higher visibility rewards contributions to the
# project).
#
# Luckily Leaflet (and, by extension, mplleaflet) can be made to work with any valid time service. To do this we can use
# the mplleaflet.fig_to_html method, which creates a string (which we'll write to a file) containing our desired
# data. Here is the method signature that we need:
# >>> mplleaflet.fig_to_html(, tiles=(, )
# For this demo we'll use the super-basic Hydda.Base tile layer.
#
# For a list of possible valid inputs:
# https://leaflet-extras.github.io/leaflet-providers/preview/
# For the full fig_to_html method signature run mplleaflet.fig_to_html? in IPython or see further:
github ResidentMario / geoplot / docs / gallery / plot_nyc_collision_factors.py View on Github external
ax2 = plt.subplot(122, projection=proj)

gplt.kdeplot(
    nyc_collision_factors[
        nyc_collision_factors['CONTRIBUTING FACTOR VEHICLE 1'] == "Failure to Yield Right-of-Way"
    ],
    cmap='Reds',
    projection=proj,
    shade=True, shade_lowest=False, 
    clip=nyc_boroughs.geometry,
    ax=ax1
)
gplt.polyplot(nyc_boroughs, zorder=1, ax=ax1)
plt.title("Failure to Yield Right-of-Way Crashes, 2016")

gplt.kdeplot(
    nyc_collision_factors[
        nyc_collision_factors['CONTRIBUTING FACTOR VEHICLE 1'] == "Lost Consciousness"
    ],
    cmap = 'Reds',
    projection=proj,
    shade=True, shade_lowest=False,
    clip=nyc_boroughs.geometry,
    ax=ax2
)
gplt.polyplot(nyc_boroughs, zorder=1, ax=ax2)
plt.title("Loss of Consciousness Crashes, 2016")

plt.savefig("nyc-collision-factors.png", bbox_inches='tight', pad_inches=0.1)