pysal.viz.splot.esda.moran_scatterplot(moran, zstandard=True, p=None, ax=None, scatter_kwds=None, fitline_kwds=None)[source]

Moran Scatterplot

moran : esda.moran instance

Values of Moran’s I Global, Bivariate and Local Autocorrelation Statistics

zstandard : bool, optional

If True, Moran Scatterplot will show z-standardized attribute and spatial lag values. Default =True.

p : float, optional

If given, the p-value threshold for significance for Local Autocorrelation analysis. Points will be colored by significance. By default it will not be colored. Default =None.

ax : Matplotlib Axes instance, optional

If given, the Moran plot will be created inside this axis. Default =None.

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. Default =None.

fig : Matplotlib Figure instance

Moran scatterplot figure

ax : matplotlib Axes instance

Axes in which the figure is plotted



>>> 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, Moran_BV,
...                         Moran_Local, Moran_Local_BV)
>>> from pysal.viz.splot.esda import moran_scatterplot

Load data and calculate weights

>>> link_to_data = examples.get_path('Guerry.shp')
>>> gdf = gpd.read_file(link_to_data)
>>> x = gdf['Suicids'].values
>>> y = gdf['Donatns'].values
>>> w = Queen.from_dataframe(gdf)
>>> w.transform = 'r'

Calculate esda.moran Objects

>>> moran = Moran(y, w)
>>> moran_bv = Moran_BV(y, x, w)
>>> moran_loc = Moran_Local(y, w)
>>> moran_loc_bv = Moran_Local_BV(y, x, w)


>>> fig, axs = plt.subplots(2, 2, figsize=(10,10),
...                         subplot_kw={'aspect': 'equal'})
>>> moran_scatterplot(moran, p=0.05, ax=axs[0,0])
>>> moran_scatterplot(moran_loc, p=0.05, ax=axs[1,0])
>>> moran_scatterplot(moran_bv, p=0.05, ax=axs[0,1])
>>> moran_scatterplot(moran_loc_bv, p=0.05, ax=axs[1,1])

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