Hatching/Fill methods?
ljwolf opened this issue · 2 comments
After reading "Choropleth Maps without Class Intervals?", I wonder whether there's a way we can get cross-hatching on fill styles for maps? The new Shelton & Poorthuis preprint uses some crosshatching for visual effect, and I think it looks better in black/white settings.
I'll probably dig into this at some point, but wanted to log this for posterity/in case someone else wants to run with this.
This can be quite simple to implement using matplotlib hatches. You specify them as strings, like '+'
and you control the density by multiplying the symbol ('+++'
). See the example below:
import matplotlib.pyplot as plt
from shapely.geometry import Point
import geopandas as gpd
fig, ax = plt.subplots(figsize=(16, 3))
for i in range(1, 7):
gpd.GeoSeries([Point(i, 0).buffer(.4)]).plot(hatch='+' * i, ax=ax, facecolor='none', edgecolor='k')
for i in range(1, 7):
gpd.GeoSeries([Point(i, 0).buffer(.4)]).plot(hatch='\\' * i, ax=ax, facecolor='none', edgecolor='k')
Note that you can have only a single hatch per collection
, can't be passed as a list.
Ooh, rad, that's very close to what I was hoping for!
I suppose the intent was to be able to make a hatch_map
function, like the existing value_by_alpha
map, that allowed you to vary the density of the hatching along with (or independent of) the color ramp. This would be a way to get an alternative bivariate choropleth strategy, varying hatching & hue instead of mixing two hues. With what you've shown above, that should definitely be possible by stratifying the data by hatching, then coloring the symbols...