%matplotlib inline
import geopandas
import seaborn
import contextily
import matplotlib.pyplot as plt
db = geopandas.read_file('../data/lux_regions.gpkg')
db['POPULATION'].plot.hist()
<matplotlib.axes._subplots.AxesSubplot at 0x7fc591022a58>
db['light_level'].plot.kde()
<matplotlib.axes._subplots.AxesSubplot at 0x7fc590eed2e8>
db[['POPULATION', 'light_level']]\
.plot.scatter('light_level',
'POPULATION')
<matplotlib.axes._subplots.AxesSubplot at 0x7fc590e5de80>
seaborn.jointplot('light_level',
'POPULATION',
db,
kind='hex')
<seaborn.axisgrid.JointGrid at 0x7fc590e495c0>
seaborn.jointplot('light_level',
'POPULATION',
db,
kind='kde')
<seaborn.axisgrid.JointGrid at 0x7fc58ec8d0b8>
seaborn.catplot(x="DISTRICT",
y="POPULATION",
data=db)
<seaborn.axisgrid.FacetGrid at 0x7fc58eb76908>
seaborn.catplot(x="DISTRICT",
y="POPULATION",
data=db,
kind='box')
<seaborn.axisgrid.FacetGrid at 0x7fc58ed8db38>
seaborn.catplot(x="DISTRICT",
y="POPULATION",
data=db,
kind='violin')
<seaborn.axisgrid.FacetGrid at 0x7fc58eaed198>
db.geometry.head()
0 POLYGON ((5.999664443592493 49.51861834298563,... 1 POLYGON ((6.347791382484162 49.76015684859829,... 2 POLYGON ((5.966652609366625 49.51287419342548,... 3 POLYGON ((6.125796013396808 49.66347171771235,... 4 POLYGON ((6.08267171189537 49.77458013764257, ... Name: geometry, dtype: object
db.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7fc58e9ba898>
ax = db.plot()
contextily.add_basemap(ax, crs=db.crs)
db.plot(column="POPULATION")
<matplotlib.axes._subplots.AxesSubplot at 0x7fc58e8fa0b8>
db.plot(column="CANTON",
categorical=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc58cd3b860>
db.plot(column="POPULATION",
scheme='equal_interval',
legend=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc58e570be0>
db.plot(column="POPULATION",
scheme='quantiles',
legend=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc583e75b70>
db.plot(column="POPULATION",
scheme='fisher_jenks',
legend=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc583dd52b0>
db.plot(column="POPULATION",
scheme='quantiles',
k=3,
legend=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc58317c470>
db.plot(column="POPULATION",
scheme='quantiles',
k=10,
legend=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc583133c18>
[See matplotlib
colormaps]
db.plot(column="POPULATION",
scheme='quantiles',
cmap='plasma')
<matplotlib.axes._subplots.AxesSubplot at 0x7fc583002320>
db.plot(column="CANTON",
cmap='Pastel1')
<matplotlib.axes._subplots.AxesSubplot at 0x7fc58303ca58>
db.plot(column="POPULATION",
scheme='quantiles',
cmap='RdPu')
<matplotlib.axes._subplots.AxesSubplot at 0x7fc582fb76a0>
z = (db['tree_count'] - db['tree_count'].median()) /\
db['tree_count'].std()
db.assign(z=z)\
.plot(column="z",
scheme="quantiles",
cmap="bwr",
legend=True)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc582e40278>
f = plt.figure()
<Figure size 432x288 with 0 Axes>
# Size
f = plt.figure(figsize=(12, 12))
<Figure size 864x864 with 0 Axes>
ax
) inside a figure (f
)f, ax = plt.subplots(1)
axs
) inside a figure (f
)f, axs = plt.subplots(2)
axs
) inside a figure (f
)f, axs = plt.subplots(1, 2)
f, ax = plt.subplots(1)
db.plot(ax=ax)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc581c61e80>
f, axs = plt.subplots(1, 2, figsize=(12, 6))
# First axis
db.plot(column='POPULATION',
scheme='quantiles',
ax=axs[0])
# Second axis
db['POPULATION'].plot.kde(ax=axs[1])
# Title
f.suptitle("Population")
# Display
plt.show()
# Transparency
db.plot(alpha=0.5)
<matplotlib.axes._subplots.AxesSubplot at 0x7fc581c1b6d8>
# Color
db.plot(color="red")
<matplotlib.axes._subplots.AxesSubplot at 0x7fc583507ef0>
seaborn
's jointplot
(hint: have a look at the seaborn
's tutorial for plotting bivariate distributions)boxen
option for a cooler alternativelight_level
light_level
against tree_count
tree_count