splot.giddy.dynamic_lisa_composite_explore

splot.giddy.dynamic_lisa_composite_explore(rose, gdf, pattern='', p=0.05, figsize=(13, 10))[source]

Interactive exploration of dynamic LISA values for different dates in a dataframe. Note: only possible in jupyter notebooks

Parameters
rosegiddy.directional.Rose instance

A Rose object, which contains (among other attributes) weights to calculate esda.moran.Moran_local values

gdfgeopandas dataframe instance

The Dataframe containing information and polygons to plot.

patternstr, optional

Option to extract all columns ending with a specific pattern. Only extracted columns will be used for comparison.

pfloat, optional

The p-value threshold for significance. Default =0.05

figsize: tuple, optional

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

Returns
None

Examples

Note: this function creates Jupyter notebook widgets, so is meant only to run in a notebook.

>>> import geopandas as gpd
>>> import pandas as pd
>>> from libpysal.weights.contiguity import Queen
>>> from libpysal import examples
>>> import numpy as np
>>> import matplotlib.pyplot as plt

If you want to see figures embedded inline in a Jupyter notebook, add a line %matplotlib inline at the top of your notebook.

>>> from giddy.directional import Rose
>>> from splot.giddy import dynamic_lisa_composite_explore

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)

plot

>>> fig = dynamic_lisa_composite_explore(rose, gdf, pattern='rel')
>>> # plt.show()

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

../_images/splot-giddy-dynamic_lisa_composite_explore-1.png