pysal.viz.splot.giddy.dynamic_lisa_vectors

pysal.viz.splot.giddy.dynamic_lisa_vectors(rose, ax=None, arrows=True, **kwargs)[source]

Plot vectors of positional transition of LISA values in Moran scatterplot

Parameters:
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.

ax : Matplotlib Axes instance, optional

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

arrows : boolean, optional

If True show arrowheads of vectors. Default =True

**kwargs : keyword arguments, optional

Keywords used for creating and designing the matplotlib.pyplot.plot() Note: ‘c’ and ‘color’ cannot be passed when attribute is not None.

Returns:
fig : Matplotlib Figure instance

Figure of dynamic LISA vectors

ax : matplotlib Axes instance

Axes in which the figure is plotted

Examples

>>> 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_vectors

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

>>> dynamic_lisa_vectors(rose)
>>> plt.show()

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

../_images/pysal-viz-splot-giddy-dynamic_lisa_vectors-1_00_00.png

customize plot

>>> dynamic_lisa_vectors(rose, arrows=False, c='r')
>>> plt.show()

(png, hires.png, pdf)

../_images/pysal-viz-splot-giddy-dynamic_lisa_vectors-1_01_00.png