pysal.viz.splot.esda.lisa_cluster

pysal.viz.splot.esda.lisa_cluster(moran_loc, gdf, p=0.05, ax=None, legend=True, legend_kwds=None, **kwargs)[source]

Create a LISA Cluster map

Parameters:
moran_loc : esda.moran.Moran_Local or Moran_Local_BV instance

Values of Moran’s Local Autocorrelation Statistic

gdf : geopandas dataframe instance

The Dataframe containing information to plot. Note that gdf will be modified, so calling functions should use a copy of the user provided gdf. (either using gdf.assign() or gdf.copy())

p : float, optional

The p-value threshold for significance. Points will be colored by significance.

ax : matplotlib Axes instance, optional

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

legend : boolean, optional

If True, legend for maps will be depicted. Default = True

legend_kwds : dict, optional

Dictionary to control legend formatting options. Example: legend_kwds={'loc': 'upper left', 'bbox_to_anchor': (0.92, 1.05)} Default = None

**kwargs : keyword arguments, optional

Keywords designing and passed to geopandas.GeoDataFrame.plot().

Returns:
fig : matplotlip Figure instance

Figure of LISA cluster map

ax : matplotlib Axes instance

Axes in which the figure is plotted

Examples

Imports

>>> import matplotlib.pyplot as plt
>>> from pysal.lib.weights.contiguity import Queen
>>> from pysal.lib import examples
>>> import geopandas as gpd
>>> from pysal.explore.esda.moran import Moran_Local
>>> from pysal.viz.splot.esda import lisa_cluster

Data preparation and statistical analysis

>>> link = examples.get_path('Guerry.shp')
>>> gdf = gpd.read_file(link)
>>> y = gdf['Donatns'].values
>>> w = Queen.from_dataframe(gdf)
>>> w.transform = 'r'
>>> moran_loc = Moran_Local(y, w)

Plotting

>>> fig = lisa_cluster(moran_loc, gdf)
>>> plt.show()

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

../_images/pysal-viz-splot-esda-lisa_cluster-1.png