Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 2 commits into from
Jul 15, 2020
Merged

Improve hatch demo #17929

merged 2 commits into from
Jul 15, 2020

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Jul 15, 2020

PR Summary

Minor improvement to the hatch demo:

  • more cross ref.
  • OSX actually has hatches. Not sure about WX or Cairo. Updated that in 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

Figure_1

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/next_api_changes/* if API changed in a backward-incompatible way

@jklymak
Copy link
Member Author

jklymak commented Jul 15, 2020

As noted before, I would combine all 4 hatch demos, but this at least improves the existing demo...

@jklymak jklymak force-pushed the doc-merged-hatch branch from 9cd0a74 to f539096 Compare July 15, 2020 04:45
@jklymak jklymak changed the title Doc merged hatch Improve hatch demo Jul 15, 2020
@jklymak jklymak force-pushed the doc-merged-hatch branch from f539096 to 5c4b240 Compare July 15, 2020 05:33
Copy link
Member

@timhoffm timhoffm left a 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

@jklymak jklymak force-pushed the doc-merged-hatch branch 2 times, most recently from 9b52ec4 to 256f661 Compare July 15, 2020 14:15
@jklymak
Copy link
Member Author

jklymak commented Jul 15, 2020

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?

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 hatch_demo.py to not be quite so ugly. The text is probably more important.

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']])
Copy link
Member

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', '.'])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less typing?

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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.

Copy link
Member

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.

Comment on lines 39 to 42
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'))
Copy link
Member

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 😍

@jklymak jklymak force-pushed the doc-merged-hatch branch from 256f661 to 6ec2fa5 Compare July 15, 2020 17:21
@jklymak jklymak force-pushed the doc-merged-hatch branch from 6ec2fa5 to a1b7862 Compare July 15, 2020 17:24
@timhoffm timhoffm added this to the v3.4.0 milestone Jul 15, 2020
@timhoffm timhoffm merged commit 660f931 into matplotlib:master Jul 15, 2020
@jklymak jklymak deleted the doc-merged-hatch branch July 15, 2020 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants