<jupyter_start><jupyter_text>Load example data<jupyter_code>import quilt
quilt.install('ResidentMario/geoplot_data')
from quilt.data.ResidentMario import geoplot_data
import geopandas as gpd

cities = gpd.read_file(geoplot_data.usa_cities())
boroughs = gpd.read_file(geoplot_data.nyc_boroughs())
dc = gpd.read_file(geoplot_data.dc_roads())
census_tracts = gpd.read_file(geoplot_data.nyc_census_tracts())
quilt.install('ResidentMario/nyc_collisions')
from quilt.data.ResidentMario import nyc_collisions
collisions = nyc_collisions.collisions()

def pointify(srs):
    try:
        lat, long = float(srs['LATITUDE']), float(srs['LONGITUDE'])
        if pd.isnull(lat) or pd.isnull(long):
            return shapely.geometry.Point((0, 0))
        else:
            return shapely.geometry.Point((long, lat))
    except ValueError:
        return shapely.geometry.Point((0, 0))

collisions = gpd.GeoDataFrame(collisions.head(5000), geometry=collisions.head(5000).apply(pointify, axis='columns'))
collisions = collisions[collisions.geometry.map(lambda srs: not (srs.x == 0))]
collisions['BOROUGH'] = collisions['BOROUGH'].str.strip().map(lambda v: np.nan if len(v) == 0 else v)<jupyter_output><empty_output><jupyter_text>Pointplot<jupyter_code>points = utils.gaussian_points()
gplt.pointplot(points, projection=gcrs.PlateCarree())
plt.savefig('../figures/pointplot/pointplot-initial.png', **savefig_kwargs)
gplt.pointplot(cities, projection=gcrs.AlbersEqualArea(), hue='ELEV_IN_FT')
plt.savefig('../figures/pointplot/pointplot-hue.png', **savefig_kwargs)
gplt.pointplot(cities, projection=gcrs.AlbersEqualArea(), hue='ELEV_IN_FT', legend=True)
plt.savefig('../figures/pointplot/pointplot-legend.png', **savefig_kwargs)
gplt.pointplot(cities, projection=gcrs.AlbersEqualArea(), hue='ELEV_IN_FT', legend=True, legend_labels=list('ABCDE'))
plt.savefig('../figures/pointplot/pointplot-legend-labels.png', **savefig_kwargs)
gplt.pointplot(cities, projection=gcrs.AlbersEqualArea(), hue='ELEV_IN_FT', legend=True, scheme='equal_interval')
plt.savefig('../figures/pointplot/pointplot-scheme.png', **savefig_kwargs)
gplt.pointplot(collisions[collisions['BOROUGH'].notnull()], projection=gcrs.AlbersEqualArea(), hue='BOROUGH',
               legend=True, categorical=True)
plt.savefig('../figures/pointplot/pointplot-categorical.png', **savefig_kwargs)
gplt.pointplot(collisions[collisions['BOROUGH'].notnull()], projection=gcrs.AlbersEqualArea(), 
               hue='BOROUGH', categorical=True,
               legend=True, legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/pointplot/pointplot-legend-kwargs.png', **savefig_kwargs)
gplt.pointplot(collisions[collisions['BOROUGH'].notnull()], projection=gcrs.AlbersEqualArea(), 
               hue='BOROUGH', categorical=True, 
               legend=True, legend_kwargs={'loc': 'upper left'},
               edgecolor='white', linewidth=0.5)
plt.savefig('../figures/pointplot/pointplot-kwargs.png', **savefig_kwargs)
more_points = utils.gaussian_points(n=3000)
data = gpd.GeoDataFrame(data={'classification': utils.classify_clusters(more_points, n=6)}, geometry=more_points)
data = data.assign(var=data['classification'] * 0.5 + pd.Series([p.x + p.y for p in data['geometry']]) + 50 + np.random.normal(size=3000) * 8)
gplt.pointplot(data, projection=gcrs.AlbersEqualArea(),
               hue='var', k=8,
               edgecolor='white', linewidth=0.5,
               legend=True, legend_kwargs={'bbox_to_anchor': (1.15, 1.0)})
plt.savefig('../figures/pointplot/pointplot-k.png', **savefig_kwargs)
more_points = utils.gaussian_points(n=3000)
data = gpd.GeoDataFrame(data={'classification': utils.classify_clusters(more_points, n=6)}, geometry=more_points)
data = data.assign(var=data['classification'] * 0.5 + pd.Series([p.x + p.y for p in data['geometry']]) + 50 + np.random.normal(size=3000) * 8)
gplt.pointplot(data, projection=gcrs.AlbersEqualArea(),
               hue='var', cmap='inferno', k=8,
               edgecolor='white', linewidth=0.5,
               legend=True, legend_kwargs={'bbox_to_anchor': (1.15, 1.0)})
plt.savefig('../figures/pointplot/pointplot-cmap.png', **savefig_kwargs)
more_points = utils.gaussian_points(n=3000)
data = gpd.GeoDataFrame(data={'classification': utils.classify_clusters(more_points, n=6)}, geometry=more_points)
data = data.assign(var=data['classification'] * 0.5 + pd.Series([p.x + p.y for p in data['geometry']]) + 50 + np.random.normal(size=3000) * 8)
gplt.pointplot(data, projection=gcrs.AlbersEqualArea(),
               hue='var', cmap='inferno', k=None,
               edgecolor='white', linewidth=0.5,
               legend=True)
plt.savefig('../figures/pointplot/pointplot-k-none.png', **savefig_kwargs)
gplt.pointplot(collisions, projection=gcrs.AlbersEqualArea(), 
               scale='NUMBER OF PERSONS INJURED',
               legend=True, legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/pointplot/pointplot-scale.png', **savefig_kwargs)
gplt.pointplot(collisions, projection=gcrs.AlbersEqualArea(), 
               scale='NUMBER OF PERSONS INJURED', limits=(0, 10),
               legend=True, legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/pointplot/pointplot-limits.png', **savefig_kwargs)
def trivial_scale(minval, maxval):
    def scalar(val):
        return 2
    return scalar

gplt.pointplot(collisions, projection=gcrs.AlbersEqualArea(), 
               scale='NUMBER OF PERSONS INJURED', scale_func=trivial_scale,
               legend=True, legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/pointplot/pointplot-scale-func.png', **savefig_kwargs)
gplt.pointplot(collisions[collisions['BOROUGH'].notnull()],
               projection=gcrs.AlbersEqualArea(),
               hue='BOROUGH', categorical=True,
               scale='NUMBER OF PERSONS INJURED', limits=(0, 10),
               legend=True, legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/pointplot/pointplot-hue-scale.png', **savefig_kwargs)
gplt.pointplot(collisions[collisions['BOROUGH'].notnull()],
               projection=gcrs.AlbersEqualArea(),
               hue='BOROUGH', categorical=True,
               scale='NUMBER OF PERSONS INJURED', limits=(0, 10),
               legend=True, legend_kwargs={'loc': 'upper left'},
               legend_var='scale')
plt.savefig('../figures/pointplot/pointplot-legend-var.png', **savefig_kwargs)<jupyter_output><empty_output><jupyter_text>Choropleth<jupyter_code>from random import randint
polygons = utils.gaussian_polygons(n=20, points=utils.gaussian_points(n=3000))
polydata = gpd.GeoDataFrame(data={'classification': [randint(1, 20) for _ in range(len(polygons))]}, geometry=polygons)
polydata['latdep'] = polydata['classification'] + np.random.normal() * 5 + 5 + polydata.geometry.envelope.exterior.map(lambda ext: ext.coords[0][1] + ext.coords[0][0])
gplt.choropleth(polydata, hue='latdep', projection=gcrs.PlateCarree())
plt.savefig('../figures/choropleth/choropleth-initial.png', **savefig_kwargs)
gplt.choropleth(polydata, hue='latdep', projection=gcrs.PlateCarree(), cmap='Blues')
plt.savefig('../figures/choropleth/choropleth-cmap.png', **savefig_kwargs)
gplt.choropleth(boroughs, projection=gcrs.AlbersEqualArea(), hue='BoroName', categorical=True)
plt.savefig('../figures/choropleth/choropleth-categorical.png', **savefig_kwargs)
gplt.choropleth(boroughs, projection=gcrs.AlbersEqualArea(), hue='BoroName', categorical=True,
                legend=True)
plt.savefig('../figures/choropleth/choropleth-legend.png', **savefig_kwargs)
gplt.choropleth(boroughs, projection=gcrs.AlbersEqualArea(), hue='BoroName', categorical=True,
                legend=True, legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/choropleth/choropleth-legend-kwargs.png', **savefig_kwargs)
gplt.choropleth(boroughs, projection=gcrs.AlbersEqualArea(), hue='BoroName', categorical=True,
                linewidth=0)
plt.savefig('../figures/choropleth/choropleth-kwargs.png', **savefig_kwargs)
from random import randint
census_tracts['mock_data'] = [randint(10, 1000) for _ in range(len(census_tracts))]
census_tracts['mock_category'] = [randint(1, 5) for _ in range(len(census_tracts))]
gplt.choropleth(census_tracts, hue='mock_data', projection=gcrs.AlbersEqualArea(),
                legend=True, edgecolor='white', linewidth=0.5, legend_kwargs={'loc': 'upper left'},
                k=2)
plt.savefig('../figures/choropleth/choropleth-k.png', **savefig_kwargs)
gplt.choropleth(census_tracts, hue='mock_data', projection=gcrs.AlbersEqualArea(),
                legend=True, edgecolor='white', linewidth=0.5, cmap='viridis',
                k=None)
plt.savefig('../figures/choropleth/choropleth-k-none.png', **savefig_kwargs)
gplt.choropleth(census_tracts, hue='mock_data', projection=gcrs.AlbersEqualArea(),
                edgecolor='white', linewidth=0.5,
                legend=True, legend_kwargs={'loc': 'upper left'},
                legend_labels=['Very Low', 'Low', 'Medium', 'High', 'Very High'])
plt.savefig('../figures/choropleth/choropleth-legend-labels.png', **savefig_kwargs)
gplt.choropleth(census_tracts, hue='mock_data', projection=gcrs.AlbersEqualArea(),
                legend=True, edgecolor='white', linewidth=0.5, legend_kwargs={'loc': 'upper left'},
                scheme='equal_interval')
plt.savefig('../figures/choropleth/choropleth-scheme.png', **savefig_kwargs)<jupyter_output><empty_output><jupyter_text>Polyplot<jupyter_code>gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea())
plt.savefig('../figures/polyplot/polyplot-initial.png', **savefig_kwargs)
gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea(), 
              linewidth=0, facecolor='lightgray')
plt.savefig('../figures/polyplot/polyplot-kwargs.png', **savefig_kwargs)
ax = gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea())
gplt.pointplot(collisions[collisions['BOROUGH'].notnull()], projection=gcrs.AlbersEqualArea(), 
               hue='BOROUGH', categorical=True, 
               legend=True, edgecolor='white', linewidth=0.5, legend_kwargs={'loc': 'upper left'},
               ax=ax)
plt.savefig('../figures/polyplot/polyplot-stacked.png', **savefig_kwargs)<jupyter_output><empty_output><jupyter_text>Aggplot<jupyter_code>from shapely.geometry import Point

collisions['LATITUDE'] = collisions['LATITUDE'].astype(float)
collisions['LONGITUDE'] = collisions['LONGITUDE'].astype(float)

latmax, latmin, longmax, longmin = collisions['LATITUDE'].max(), collisions['LATITUDE'].min(),\
                                   collisions['LONGITUDE'].max(), collisions['LONGITUDE'].min()
    
def genpattern(srs):
    return (srs['LATITUDE'] - latmin) / (latmax - latmin)

collisions['LATDEP'] = collisions.apply(genpattern, axis='columns')
gplt.aggplot(collisions, projection=gcrs.PlateCarree(), hue='LATDEP')
plt.savefig('../figures/aggplot/aggplot-initial.png', **savefig_kwargs)
gplt.aggplot(collisions, nmin=10, nmax=250, nsig=5, projection=gcrs.PlateCarree(), hue='LATDEP', cmap='Blues')
plt.savefig('../figures/aggplot/aggplot-quadtree-tuned.png', **savefig_kwargs)
gplt.aggplot(collisions, projection=gcrs.PlateCarree(), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
             by='BOROUGH')
plt.savefig('../figures/aggplot/aggplot-hulls.png', **savefig_kwargs)
boroughs_2 = boroughs.set_index('BoroName')
boroughs_2.index = [b.upper() for b in boroughs_2.index]
gplt.aggplot(collisions, projection=gcrs.PlateCarree(), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
             geometry=boroughs_2, by='BOROUGH')
plt.savefig('../figures/aggplot/aggplot-by.png', **savefig_kwargs)
boroughs_2 = boroughs.set_index('BoroName')
boroughs_2.index = [b.upper() for b in boroughs_2.index]
gplt.aggplot(collisions, projection=gcrs.PlateCarree(), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
             geometry=boroughs_2, by='BOROUGH', agg=len)
plt.savefig('../figures/aggplot/aggplot-agg.png', **savefig_kwargs)
gplt.aggplot(collisions, projection=gcrs.PlateCarree(), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
             geometry=boroughs_2, by='BOROUGH', agg=len, legend=False)
plt.savefig('../figures/aggplot/aggplot-legend.png', **savefig_kwargs)
gplt.aggplot(collisions, projection=gcrs.PlateCarree(), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
             geometry=boroughs_2, by='BOROUGH', agg=len, linewidth=0)
plt.savefig('../figures/aggplot/aggplot-kwargs.png', **savefig_kwargs)
gplt.aggplot(collisions, projection=gcrs.PlateCarree(), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
             geometry=boroughs_2, by='BOROUGH', agg=len, linewidth=0, 
             legend_kwargs={'orientation': 'horizontal'})
plt.savefig('../figures/aggplot/aggplot-legend-kwargs.png', **savefig_kwargs)<jupyter_output><empty_output><jupyter_text>Cartogram<jupyter_code>boroughs['Population'] = [378, 1951, 2300, 1487, 1203]
boroughs['Population Density'] = boroughs['Population'] / boroughs['Shape_Area']
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea())
plt.savefig('../figures/cartogram/cartogram-initial.png', **savefig_kwargs)
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(),
               trace=False, legend=True)
plt.savefig('../figures/cartogram/cartogram-trace-legend.png', **savefig_kwargs)
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(),
               trace=False, legend=True, legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/cartogram/cartogram-legend-kwargs.png', **savefig_kwargs)
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(), legend=True,
               legend_values=[2.32779655e-07, 6.39683197e-07, 1.01364661e-06, 1.17380941e-06, 2.33642596e-06][::-1],
               legend_labels=['Manhattan', 'Brooklyn', 'Queens', 'The Bronx', 'Staten Island'],
               legend_kwargs={'loc': 'upper left'})
plt.savefig('../figures/cartogram/cartogram-legend-labels.png', **savefig_kwargs)
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(),
               edgecolor='darkgreen')
plt.savefig('../figures/cartogram/cartogram-kwargs.png', **savefig_kwargs)
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(),
               trace_kwargs={'edgecolor': 'lightgreen'})
plt.savefig('../figures/cartogram/cartogram-trace-kwargs.png', **savefig_kwargs)
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(),
               limits=(0.5, 1))
plt.savefig('../figures/cartogram/cartogram-limits.png', **savefig_kwargs)
def trivial_scale(minval, maxval):
    def scalar(val):
        return 0.5
    return scalar

gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(),
               limits=(0.5, 1), scale_func=trivial_scale)
plt.savefig('../figures/cartogram/cartogram-scale-func.png', **savefig_kwargs)
gplt.cartogram(boroughs, scale='Population Density', projection=gcrs.AlbersEqualArea(),
               hue='Population Density', k=None, cmap='Blues')
plt.savefig('../figures/cartogram/cartogram-hue.png', **savefig_kwargs)<jupyter_output><empty_output><jupyter_text>KDEPlot<jupyter_code>ax = gplt.kdeplot(collisions, projection=gcrs.AlbersEqualArea())
plt.savefig('../figures/kdeplot/kdeplot-initial.png', **savefig_kwargs)
ax = gplt.kdeplot(collisions, projection=gcrs.AlbersEqualArea())
gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea(), ax=ax)
plt.savefig('../figures/kdeplot/kdeplot-overlay.png', **savefig_kwargs)
ax = gplt.kdeplot(collisions, projection=gcrs.AlbersEqualArea(), shade=True)
gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea(), ax=ax)
plt.savefig('../figures/kdeplot/kdeplot-shade.png', **savefig_kwargs)
ax = gplt.kdeplot(collisions, projection=gcrs.AlbersEqualArea(), n_levels=30)
gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea(), ax=ax)
plt.savefig('../figures/kdeplot/kdeplot-n-levels.png', **savefig_kwargs)
ax = gplt.kdeplot(collisions, projection=gcrs.AlbersEqualArea(), cmap='Purples')
gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea(), ax=ax)
plt.savefig('../figures/kdeplot/kdeplot-cmap.png', **savefig_kwargs)
ax = gplt.kdeplot(collisions, projection=gcrs.AlbersEqualArea(),
                  shade=True, clip=boroughs.geometry)
gplt.polyplot(boroughs, projection=gcrs.AlbersEqualArea(), ax=ax)
plt.savefig('../figures/kdeplot/kdeplot-clip.png', **savefig_kwargs)<jupyter_output><empty_output><jupyter_text>Sankey<jupyter_code>la_flights = gpd.read_file(geoplot_data.la_flights())
la_flights = la_flights.assign(
    start=la_flights.geometry.map(lambda mp: mp[0]),
    end=la_flights.geometry.map(lambda mp: mp[1])
)
ax = gplt.sankey(la_flights, start='start', end='end', projection=gcrs.PlateCarree())
ax.set_global(); ax.coastlines()
plt.savefig('../figures/sankey/sankey-geospatial-context.png', **savefig_kwargs)
ax = gplt.sankey(la_flights, start='start', end='end', projection=gcrs.Orthographic())
ax.set_global(); ax.coastlines(); ax.outline_patch.set_visible(True)
plt.savefig('../figures/sankey/sankey-greatest-circle-distance.png', **savefig_kwargs)
import cartopy.crs as ccrs
ax = gplt.sankey(la_flights, start='start', end='end', projection=gcrs.PlateCarree(), path=ccrs.PlateCarree())
ax.set_global(); ax.coastlines()
plt.savefig('../figures/sankey/sankey-path-projection.png', **savefig_kwargs)
network = utils.uniform_random_global_network()
gplt.sankey(dc, path=dc.geometry, projection=gcrs.AlbersEqualArea(), scale='aadt')
plt.savefig('../figures/sankey/sankey-path.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='mock_variable')
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-hue.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='mock_variable', cmap='RdYlBu')
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-cmap.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='mock_variable', cmap='RdYlBu',
                 legend=True)
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-legend.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='mock_variable', cmap='RdYlBu',
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)})
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-legend-kwargs.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='mock_variable', cmap='RdYlBu',
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)},
                 legend_labels=['Very Low', 'Low', 'Average', 'High', 'Very High'])
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-legend-labels.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='mock_variable', cmap='RdYlBu',
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)},
                 k=3)
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-k.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='mock_variable', cmap='RdYlBu',
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)},
                 k=3, scheme='equal_interval')
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-scheme.png', **savefig_kwargs)
network['above_meridian'] = network['from'].map(lambda point: point.y > 0)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 hue='above_meridian', cmap='RdYlBu',
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)},
                 categorical=True)
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-categorical.png', **savefig_kwargs)
network['mock_data'] = [np.random.normal(100, 50) for _ in range(len(network))]
ax = gplt.sankey(la_flights, projection=gcrs.PlateCarree(),
                 extent=(-125.0011, -66.9326, 24.9493, 49.5904),
                 start='start', end='end',
                 scale='Passengers',
                 limits=(0.1, 5),
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)})
ax.coastlines()
plt.savefig('../figures/sankey/sankey-scale.png', **savefig_kwargs)
def trivial_scale(minval, maxval):
    return lambda v: 1

ax = gplt.sankey(la_flights, projection=gcrs.PlateCarree(),
                 extent=(-125.0011, -66.9326, 24.9493, 49.5904),
                 start='start', end='end',
                 scale='Passengers', scale_func=trivial_scale,
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)})
ax.coastlines()
plt.savefig('../figures/sankey/sankey-scale-func.png', **savefig_kwargs)
ax = gplt.sankey(network, projection=gcrs.PlateCarree(),
                 start='from', end='to',
                 scale='mock_data',
                 legend=True, legend_kwargs={'bbox_to_anchor': (1.1, 1.0)},
                 hue='mock_data', legend_var="hue")
ax.set_global()
ax.coastlines()
plt.savefig('../figures/sankey/sankey-legend-var.png', **savefig_kwargs)<jupyter_output><empty_output><jupyter_text>Voronoi<jupyter_code>boroughs = gpd.read_file(geoplot_data.nyc_boroughs())
injurious_collisions = gpd.read_file(geoplot_data.nyc_injurious_collisions())
ax = gplt.voronoi(injurious_collisions.head(1000))
gplt.polyplot(boroughs, ax=ax)
plt.savefig('../figures/voronoi/voronoi-simple.png', **savefig_kwargs)
ax = gplt.voronoi(injurious_collisions.head(1000), hue='NUMBER OF PERSONS INJURED', cmap='Reds')
gplt.polyplot(boroughs, ax=ax)
plt.savefig('../figures/voronoi/voronoi-cmap.png', **savefig_kwargs)
ax = gplt.voronoi(injurious_collisions.head(1000), hue='NUMBER OF PERSONS INJURED', cmap='Reds', 
                  clip=boroughs.geometry)
gplt.polyplot(boroughs, ax=ax)
plt.savefig('../figures/voronoi/voronoi-clip.png', **savefig_kwargs)
ax = gplt.voronoi(injurious_collisions.head(1000), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
                  clip=boroughs.geometry,
                  legend=True, legend_kwargs={'loc': 'upper left'},
                  linewidth=0.5, edgecolor='white',
                 )
gplt.polyplot(boroughs, ax=ax)
plt.savefig('../figures/voronoi/voronoi-kwargs.png', **savefig_kwargs)
ax = gplt.voronoi(injurious_collisions.head(1000), 
                  hue='NUMBER OF PERSONS INJURED', cmap='Reds', k=5, scheme='fisher_jenks',
                  clip=boroughs.geometry,
                  legend=True, legend_kwargs={'loc': 'upper left'},
                  linewidth=0.5, edgecolor='white', 
                 )
gplt.polyplot(boroughs, ax=ax)
plt.savefig('../figures/voronoi/voronoi-scheme.png', **savefig_kwargs)
ax = gplt.voronoi(injurious_collisions.head(1000), hue='NUMBER OF PERSONS INJURED', cmap='Reds',
                  edgecolor='white', clip=boroughs.geometry,
                  legend=True,
                  linewidth=0.5, categorical=True
             )
gplt.polyplot(boroughs, linewidth=1, ax=ax)
plt.savefig('../figures/voronoi/voronoi-multiparty.png', **savefig_kwargs)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1653580068757693, 'fraction_numerical': 0.015024829166843513, 'mean_word_length': 4.599334600760456, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '267773', 'license': 'MIT', 'n_tokens_mistral': 8733, 'n_tokens_neox': 8058, 'n_words': 1071, 'path': 'notebooks/generate-api-reference-images.ipynb', 'repo_name': 'lmmarsano/geoplot', 'size': '23561'}