pysal.viz.splot.mapping.vba_legend

pysal.viz.splot.mapping.vba_legend(rgb_bins, alpha_bins, cmap, ax=None)[source]

Creates Value by Alpha heatmap used as choropleth legend.

Parameters:
rgb_bins : pysal.mapclassify instance

Object of classified values used for rgb. Can be created with mapclassify_bin() or pysal.mapclassify.

alpha_bins : pysal.mapclassify instance

Object of classified values used for alpha. Can be created with mapclassify_bin() or pysal.mapclassify.

ax : matplotlib Axes instance, optional

Axes in which to plot the figure in multiple Axes layout. Default = None

Returns:
fig : matplotlip Figure instance

Figure of Value by Alpha heatmap

ax : matplotlib Axes instance

Axes in which the figure is plotted

Examples

Imports

>>> from pysal.lib import examples
>>> import geopandas as gpd
>>> import matplotlib.pyplot as plt
>>> import matplotlib
>>> import numpy as np
>>> from pysal.viz.splot.mapping import vba_legend, mapclassify_bin

Load Example Data

>>> link_to_data = examples.get_path('columbus.shp')
>>> gdf = gpd.read_file(link_to_data)
>>> x = gdf['HOVAL'].values
>>> y = gdf['CRIME'].values

Classify your data

>>> rgb_bins = mapclassify_bin(x, 'quantiles')
>>> alpha_bins = mapclassify_bin(y, 'quantiles')

Plot your legend

>>> fig, _ = vba_legend(rgb_bins, alpha_bins, cmap='RdBu')
>>> plt.show()

(Source code, png, hires.png, pdf)

../_images/pysal-viz-splot-mapping-vba_legend-1.png