Search
south
import sys
import os
sys.path.append(os.path.abspath('..'))
import mapclassify as mc
import libpysal
import geopandas as gpd
import matplotlib.pyplot as plt

%matplotlib inline
_ = libpysal.examples.load_example('South')
df = gpd.read_file(libpysal.examples.get_path('south.shp'))
hr60_q10 = mc.Quantiles(df['HR60'], k=10)
hr60_q10
Quantiles             

   Interval      Count
----------------------
[ 0.00,  0.00] |   180
( 0.00,  2.50] |   103
( 2.50,  3.93] |   141
( 3.93,  5.10] |   141
( 5.10,  6.25] |   141
( 6.25,  7.62] |   141
( 7.62,  9.19] |   141
( 9.19, 10.98] |   141
(10.98, 14.31] |   141
(14.31, 92.94] |   142
fig, ax = plt.subplots(figsize=(12,10), subplot_kw={'aspect':'equal'})
df.assign(cl=hr60_q10.yb).plot(column='cl', categorical=True, \
                              k=10, cmap='OrRd', linewidth=0.1, ax=ax, \
                              edgecolor='white', legend=True)
ax.set_axis_off()
plt.title('HR60 Deciles')
plt.savefig('hr60q10.png')
import numpy as np
np.random.seed(12345)
hr60_fj10 = mc.FisherJenks(df['HR60'], k=10)
hr60_fj10
FisherJenks           

   Interval      Count
----------------------
[ 0.00,  1.71] |   216
( 1.71,  4.45] |   278
( 4.45,  7.08] |   287
( 7.08, 10.02] |   288
(10.02, 13.59] |   176
(13.59, 19.60] |   121
(19.60, 28.77] |    34
(28.77, 40.74] |     8
(40.74, 53.30] |     3
(53.30, 92.94] |     1
fig, ax = plt.subplots(figsize=(12,10), subplot_kw={'aspect':'equal'})
df.assign(cl=hr60_fj10.yb).plot(column='cl', categorical=True, \
                              k=10, cmap='OrRd', linewidth=0.1, ax=ax, \
                              edgecolor='white', legend=True)
ax.set_axis_off()
plt.title('HR60 Fisher-Jenks')
plt.savefig('hr60fj10.png')
hr60_mb10 = mc.MaximumBreaks(df['HR60'], k=10)


fig, ax = plt.subplots(figsize=(12,10), subplot_kw={'aspect':'equal'})
df.assign(cl=hr60_mb10.yb).plot(column='cl', categorical=True, \
                              k=10, cmap='OrRd', linewidth=0.1, ax=ax, \
                              edgecolor='white', legend=True)
ax.set_axis_off()
plt.title('HR60 Maximum Breaks')
plt.savefig('hr60mb10.png')
hr60_ea10 = mc.EqualInterval(df['HR60'], k=10)


fig, ax = plt.subplots(figsize=(12,10), subplot_kw={'aspect':'equal'})
df.assign(cl=hr60_ea10.yb).plot(column='cl', categorical=True, \
                              k=10, cmap='OrRd', linewidth=0.1, ax=ax, \
                              edgecolor='white', legend=True)
ax.set_axis_off()
plt.title('HR60 Equal Interval')
Text(0.5, 1, 'HR60 Equal Interval')
fig, ax = plt.subplots(figsize=(12,10), subplot_kw={'aspect':'equal'})
df.plot(column='HR60', ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x7fe872dec160>
hr60_q5 = mc.Quantiles(df['HR60'], k=5)
hr60_q5
Quantiles             

   Interval      Count
----------------------
[ 0.00,  2.50] |   283
( 2.50,  5.10] |   282
( 5.10,  7.62] |   282
( 7.62, 10.98] |   282
(10.98, 92.94] |   283