pysal.viz.splot.esda.plot_moran

pysal.viz.splot.esda.plot_moran(moran, zstandard=True, scatter_kwds=None, fitline_kwds=None, **kwargs)[source]

Global Moran’s I simulated reference distribution and scatterplot.

Parameters:
moran : esda.moran.Moran instance

Values of Moran’s I Global Autocorrelation Statistics

zstandard : bool, optional

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

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

**kwargs : keyword arguments, optional

Keywords used for creating and designing the figure, passed to seaborne.kdeplot.

Returns:
fig : Matplotlib Figure instance

Moran scatterplot and reference distribution figure

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
>>> from pysal.viz.splot.esda import plot_moran

Load data and calculate weights

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

Calculate Global Moran

>>> moran = Moran(y, w)

plot

>>> plot_moran(moran)
>>> plt.show()

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

../_images/pysal-viz-splot-esda-plot_moran-1_00_00.png

customize plot

>>> plot_moran(moran, zstandard=False,
...            fitline_kwds=dict(color='#4393c3'))
>>> plt.show()

(png, hires.png, pdf)

../_images/pysal-viz-splot-esda-plot_moran-1_01_00.png