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

Moran Scatterplot

moranesda.moran instance

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

zstandardbool, optional

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

pfloat, 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.

aspect_equalbool, optional

If True, Axes will show the same aspect or visual proportions for Moran Scatterplot.

axMatplotlib Axes instance, optional

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

scatter_kwdskeyword arguments, optional

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

fitline_kwdskeyword arguments, optional

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

figMatplotlib Figure instance

Moran scatterplot figure

axmatplotlib Axes instance

Axes in which the figure is plotted



>>> import matplotlib.pyplot as plt
>>> from libpysal.weights.contiguity import Queen
>>> from libpysal import examples
>>> import geopandas as gpd
>>> from esda.moran import (Moran, Moran_BV,
...                         Moran_Local, Moran_Local_BV)
>>> from 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])
>>> plt.show()

(Source code)