-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix Hatch Color #27949
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
Fix Hatch Color #27949
Conversation
I'm not sure about how to solve these code-cov failing tests, can someone help me out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the order of these lines matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the facecolor
attribute must be defined first to use it later in the _set_edgecolor
method
Could somebody take a look at this patch?
Please add a test to verify the new behaviour. Otherwise future changes might inadvertently break it again.
https://matplotlib.org/devdocs/devel/testing.html
Updating the hatch color depending on the face color does not feel right. While it may result in hatching for the given example, it may result in strange order dependent behavior. Say, your patch face Color is white and you want to change that to grey with white hatching. With this PR, it only works for
patch.set_facecolor(„grey")
patch.set_edgecolor(„white")
But not if you change the order of both lines.
I’m on mobile, so cannot dig fully into the context, but I have the impression that the underlying problem of the original issue may be that hatch color and face color are the same so that the hatch is drawn but not visible. Can you confirm this? If that is the case, other fixes (or maybe no fix at all) are needed - which depends on the context.
Updating the hatch color depending on the face color does not feel right. While it may result in hatching for the given example, it may result in strange order dependent behavior. Say, your patch face Color is white and you want to change that to grey with white hatching. With this PR, it only works for
patch.set_facecolor(„grey") patch.set_edgecolor(„white")
But not if you change the order of both lines.
I’m on mobile, so cannot dig fully into the context, but I have the impression that the underlying problem of the original issue may be that hatch color and face color are the same so that the hatch is drawn but not visible. Can you confirm this? If that is the case, other fixes (or maybe no fix at all) are needed - which depends on the context.
Yes you are right, the hatch color is set based on the edge color which is set to (0,0,0,0). Hence, the patch. I probably need to default to rcParams if the face color and edge colors match?
Ok, so the issue here is that the default edge color for the figure patch is such that the hatching is invisible. I'd then claim that everything works as intended and we should close both this PR and the issue. The resolution to the issue would be on the user side to set an edge color when they want hatching. Ping @anntzer for confirmation.
Yes, looking at it again the issue was just invalid and arising because the patch edgecolor also defaults to white. Thanks for resurrecting the discussion, though!
The resolution to the issue would be on the user side to set an edge color when they want hatching
Should we add this to the docs then? Recommending to always set edge color when setting hatches, as it is confusing to not see a hatch when it is specified explicitly
This applies only to the figure patch, because that has different defaults. We don’t have specific documentation for the figure patch and IMHO it’s really rare to hatch the figure. I wouldn’t clutter the regular docs with that.
PR summary
Closes #8865
Simple fix by checking if face-color is the same as edge-color for a patch, If yes, do not update hatch-color
Gives the needed output:
imagePR checklist