from plotnine import *
import geodatasets
import geopandas as gp
= gp.read_file(geodatasets.get_path("geoda.chicago_commpop"))
chicago = gp.read_file(geodatasets.get_path("geoda.groceries")) groceries
Maps
(
ggplot(chicago)+ geom_map()
+ coord_fixed()
)
(="POP2010"))
ggplot(chicago, aes(fill+ geom_map()
+ coord_fixed()
)
(="POP2010"))
ggplot(chicago, aes(fill+ geom_map()
#+ scale_fill_cmap('plasma')
#+ scale_fill_gradientn(["green", "purple", "papayawhip"])
#+ scale_fill_gradient(low="green", high="blue")
#+ scale_fill_gradient2()
)# scale_fill_gradient
# scale_fill_continuous
(
ggplot(chicago)+ geom_map(fill=None)
#+ geom_map(fill=None)
+ theme_void()
+ coord_fixed()
)
Missing data
import numpy as np
= chicago.copy()
chi_missing 50), 'POP2010'] = np.nan
chi_missing.loc[np.random.choice(chicago.index,
(="POP2010"))
ggplot(chi_missing, aes(fill+ geom_map()
)
(="POP2010"))
ggplot(chi_missing, aes(fill+ geom_map(color="none")
+ theme_void()
+ scale_fill_continuous(na_value="lightgrey")
)
(
ggplot()+ geom_map(data=chicago, fill=None)
+ geom_map(data=groceries.to_crs(chicago.crs), color="green")
+ theme_void()
+ coord_fixed()
)