-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Improve hatch demo #17929
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
Improve hatch demo #17929
Conversation
As noted before, I would combine all 4 hatch demos, but this at least improves the existing demo... |
9cd0a74
to
f539096
Compare
f539096
to
5c4b240
Compare
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.
👍 For the texts and links.
I'm also 👍 on merging the demos (with the execption of the reference); or better say write a new single demo from scratch as the existing example plots are not really good IMHO. I have aleady some more real-world application drafts in the making.
Therefore, I'm a bit reluctant fiddling now with the single demos.
This removes important recently added information (density and combination) from the reference. And it instead adds back in the ugly plot from the hatch demo. Is that intentional?
c.f. current refernce https://matplotlib.org/devdocs/gallery/shapes_and_collections/hatch_style_reference.html
9b52ec4
to
256f661
Compare
I made a mistake with the reference file. It was supposed to just change the first paragraph, and that's been fixed. Not sure what the second half of your sentence means. This PR mildly changes the demo in We could merge the demos, but again the problem of losing permanent links is real. But anyway, that's beyond what I'm interested to do in this PR. Anyone should feel free to close if they don't deem this an improvement. |
ax1.bar(x, y2, bottom=y1, edgecolor='black', hatch='//') | ||
ax1.set_xticks([1.5, 2.5, 3.5, 4.5]) | ||
fig = plt.figure() | ||
axs = fig.subplot_mosaic([['bar1', 'patches'], ['bar2', 'patches']]) |
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.
Happy dance that you're using mosiac (for the record fig, axs = plt.subplot_mosaic also works) 'cause I so think it's well suited for these kinds of things.
But also not clear why you're reassigning them:
ax = axs['bar1']
ax.bar(x, y2, bottom=y1, edgecolor='black', hatch=['*', 'o', 'O', '.'])
versus using 'em directly:
axs['bar'].bar(x, y2, bottom=y1, edgecolor='black', hatch=['*', 'o', 'O', '.'])
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.
Less typing?
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.
I don't think it's that much less and I think the reassignment especially w/ same variable name is potential unnecessary source of failure.
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.
... wrote out the long form
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.
I think the reassignment especially w/ same variable name is potential unnecessary source of failure.
I'd argue the opposite - its less prone to typos and easier to refactor.
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.
I agree it's easier to refactor, but it's prone to leaving out that assignment statement and therefore messing up all the references.
ax.fill_between(x, np.sin(x) * 4 + 30, y2=0, hatch='///', zorder=2, fc='c') | ||
ax.add_patch(Ellipse((4, 50), 10, 10, fill=True, hatch='*', facecolor='y')) | ||
ax.add_patch(Polygon([(10, 20), (30, 50), (50, 10)], hatch='\\/...', | ||
facecolor='g')) |
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.
I'm turning this into a twitter game 'cause 😍
256f661
to
6ec2fa5
Compare
6ec2fa5
to
a1b7862
Compare
PR Summary
Minor improvement to the hatch demo:
hatch_style_reference
and added a couple of crosslinks.New demo is at:
https://41352-1385122-gh.circle-artifacts.com/0/doc/build/html/gallery/shapes_and_collections/hatch_demo.html#sphx-glr-gallery-shapes-and-collections-hatch-demo-py
Lightly modified hatch_reference_style.py:
https://41352-1385122-gh.circle-artifacts.com/0/doc/build/html/gallery/shapes_and_collections/hatch_style_reference.html#sphx-glr-gallery-shapes-and-collections-hatch-style-reference-py
PR Checklist