Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hatching/Fill methods? #35

Open
ljwolf opened this issue Nov 6, 2018 · 2 comments
Open

Hatching/Fill methods? #35

ljwolf opened this issue Nov 6, 2018 · 2 comments
Labels
wishlist Functionality that should be supported in future

Comments

@ljwolf
Copy link
Member

ljwolf commented Nov 6, 2018

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.

@ljwolf ljwolf added the wishlist Functionality that should be supported in future label Nov 6, 2018
@slumnitz slumnitz added this to wishlist in Splot roadmap May 6, 2019
@martinfleis
Copy link
Member

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')

download

for i in range(1, 7):
    gpd.GeoSeries([Point(i, 0).buffer(.4)]).plot(hatch='\\' * i, ax=ax, facecolor='none', edgecolor='k')

download-1

Note that you can have only a single hatch per collection, can't be passed as a list.

@ljwolf
Copy link
Member Author

ljwolf commented Jul 9, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wishlist Functionality that should be supported in future
Projects
Splot roadmap
  
wishlist
Development

No branches or pull requests

2 participants