pysal.viz.splot.esda.plot_local_autocorrelation

pysal.viz.splot.esda.plot_local_autocorrelation(moran_loc, gdf, attribute, p=0.05, region_column=None, mask=None, mask_color='#636363', quadrant=None, legend=True, scheme='Quantiles', cmap='YlGnBu', figsize=(15, 4), scatter_kwds=None, fitline_kwds=None)[source]

Produce three-plot visualisation of Moran Scatteprlot, LISA cluster and Choropleth maps, with Local Moran region and quadrant masking

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

Values of Moran’s Local Autocorrelation Statistic

gdf : geopandas dataframe

The Dataframe containing information to plot the two maps.

attribute : str

Column name of attribute which should be depicted in Choropleth map.

p : float, optional

The p-value threshold for significance. Points and polygons will be colored by significance. Default = 0.05.

region_column: string, optional

Column name containing mask region of interest. Default = None

mask: str, optional

Identifier or name of the region to highlight. Default = None

mask_color: str, optional

Color of mask. Default = ‘#636363’

quadrant : int, optional

Quadrant 1-4 in scatterplot masking values in LISA cluster and Choropleth maps. Default = None

figsize: tuple, optional

W, h of figure. Default = (15,4)

legend: boolean, optional

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

scheme: str, optional

Name of PySAL classifier to be used. Default = ‘Quantiles’

cmap: str, optional

Name of matplotlib colormap used for plotting the Choropleth. Default = ‘YlGnBu’

scatter_kwds : keyword arguments, optional

Keywords used for creating and designing the scatter points. Default =None.

fitline_kwds : keyword arguments, optional

Keywords used for creating and designing the moran fitline in the scatterplot. Default =None.

Returns:
fig : Matplotlib figure instance

Moran Scatterplot, LISA cluster map and Choropleth.

axs : list of Matplotlib axes

Lisat of Matplotlib axes 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 plot_local_autocorrelation

Data preparation and 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 with quadrant mask and region mask

>>> fig = plot_local_autocorrelation(moran_loc, gdf, 'Donatns', p=0.05,
...                                  region_column='Dprtmnt',
...                                  mask=['Ain'], quadrant=1)
>>> plt.show()

(Source code)