-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Multi hatching in ax.stackplot()
#27146
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
Comments
Hello! |
To me this request seems analogous to the hatch parameter added to pie at v3.7. |
Good first issue - notes for new contributorsThis issue is suited to new contributors because it does not require understanding of the Matplotlib internals. To get started, please see our contributing guide. We do not assign issues. Check the Development section in the sidebar for linked pull requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please collaborate on the work by reviewing it rather than duplicating it in a competing PR. If something is unclear, please reach out on any of our communication channels. |
This is a reaonable request. It's a good first issue because the change is local in matplotlib/lib/matplotlib/stackplot.py Lines 18 to 127 in 3958242
and you can simply handle hatching analogous to the existing color handling. |
To me, uniform hatching covering the whole data area is purely decorative and you still need colours to understand the data. As oppose to when you have individual hatching styles. Then you can go only with the hatching fill and remove the colours. Scientific papers are often required to be made in a way so you can print them in black and white. And they often use hatching for this purpose to distinguish between different areas. |
Hi! I agree on the usefulness of having different hatching styles in a stack plot, and had a go at implementing this following the guidance above (many thanks for making this so clear and newbie-friendly BTW!) in the draft PR: #27158 |
Problem
ax.stackplot()
is used for conveniently plotting stacked area plot.The documentation says that any
**kwargs
is passed on toax.fill_between
.So, it all works fine if I work with colours, but not so much with hatching pattern.
If I want to add hatching, this is what I get by default:
The outcome:

But I would be more interested in getting something like this:

Proposed solution
The calling signature would be the same as before with exception that the
hatch
parameter would accept e.g. a list withhatching
styles you want to use.Example:
The example I've used above in the problem was create using the code below and in this case it varies the hatching by the density:
The text was updated successfully, but these errors were encountered: