pysal.viz.splot.giddy.dynamic_lisa_composite(rose, gdf, p=0.05, figsize=(13, 10))[source]

Composite visualisation for dynamic LISA values over two points in time. Includes dynamic lisa heatmap, dynamic lisa rose plot, and LISA cluster plots for both, compared points in time.

rose : giddy.directional.Rose instance

A Rose object, which contains (among other attributes) LISA values at two points in time, and a method to perform inference on those.

gdf : geopandas dataframe instance

The GeoDataFrame containing information and polygons to plot.

p : float, optional

The p-value threshold for significance. Default =0.05.

figsize: tuple, optional

W, h of figure. Default =(13,10)

fig : Matplotlib Figure instance

Dynamic lisa composite figure.

axs : matplotlib Axes instance

Axes in which the figure is plotted.


>>> import geopandas as gpd
>>> import pandas as pd
>>> from pysal.lib.weights.contiguity import Queen
>>> from pysal.lib import examples
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from pysal.explore.giddy.directional import Rose
>>> from pysal.viz.splot.giddy import dynamic_lisa_composite

get csv and shp files

>>> shp_link = examples.get_path('us48.shp')
>>> df = gpd.read_file(shp_link)
>>> income_table = pd.read_csv(examples.get_path("usjoin.csv"))

calculate relative values

>>> for year in range(1969, 2010):
...     income_table[str(year) + '_rel'] = (
...         income_table[str(year)] / income_table[str(year)].mean())

merge to one gdf

>>> gdf = df.merge(income_table,left_on='STATE_NAME',right_on='Name')

retrieve spatial weights and data for two points in time

>>> w = Queen.from_dataframe(gdf)
>>> w.transform = 'r'
>>> y1 = gdf['1969_rel'].values
>>> y2 = gdf['2000_rel'].values

calculate rose Object

>>> Y = np.array([y1, y2]).T
>>> rose = Rose(Y, w, k=5)


>>> dynamic_lisa_composite(rose, gdf)

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


customize plot

>>> fig, axs = dynamic_lisa_composite(rose, gdf)
>>> axs[0].set_ylabel('1996')
>>> axs[0].set_xlabel('2009')
>>> axs[1].set_title('LISA cluster for 1996')
>>> axs[3].set_title('LISA clsuter for 2009')

(png, hires.png, pdf)