Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

19195 rotated markers#20914

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dstansby merged 22 commits intomatplotlib:masterfromdeep-jkl:19195-rotated-markers
Oct 5, 2021

Conversation

deep-jkl
Copy link
Contributor

@deep-jkldeep-jkl commentedAug 26, 2021
edited
Loading

PR Summary

Add user supplied transforms and join/cap styles …

Improvement was done in instantiating new instance utilizing deep copy should preserve immutability of MarkerStyle members (e.g. Path, or Transform). However deepcopy of MarkerStyle(r"$|||$") fails. Originally it was needed in lines.py, but I think it can be optimized out to avoid multiple re-instantiation of MarkerStyle.

I followed the discussion for issue#19195 and tried several cases:

frommatplotlibimporttransformsimportmatplotlib.pyplotaspltimportmatplotlib.pyplotaspltfrommatplotlib.linesimportLine2Dfrommatplotlib.transformsimportAffine2Dfrommatplotlib.markersimportMarkerStyle,JoinStyle,CapStyletext_style=dict(horizontalalignment='right',verticalalignment='center',fontsize=12,fontfamily='monospace')marker_style=dict(linestyle=':',color='0.8',markersize=10,markerfacecolor="tab:blue",markeredgecolor="tab:blue")defformat_axes(ax):ax.margins(0.2)ax.set_axis_off()ax.invert_yaxis()fig,ax=plt.subplots()fig.suptitle('Marker fillstyle',fontsize=14)fig.subplots_adjust(left=0.4)marker_colors=dict(markersize=15,markerfacecolor='tab:blue',markerfacecoloralt='lightsteelblue',markeredgecolor='brown')fory,fill_styleinenumerate(Line2D.fillStyles[1:-1]):ax.text(-0.5,y,repr(fill_style),**text_style)ax.plot([0,5],[y]*2,linestyle=":",color='darkgrey')forx,thetainenumerate([0,10,15,20,30,45]):ax.plot(x,y,marker=MarkerStyle("o",fill_style,transform=Affine2D().rotate_deg(theta)),**marker_colors)ax.text(x,4,f"{theta}°",**text_style)format_axes(ax)plt.show()

fillstyle

fig,ax=plt.subplots()fig.suptitle('Marker CapStyle',fontsize=14)fig.subplots_adjust(left=0.1)marker_inner=dict(markersize=35,markerfacecolor='tab:blue',markerfacecoloralt='lightsteelblue',markeredgecolor='brown',markeredgewidth=8,                    )marker_outer=dict(markersize=35,markerfacecolor='tab:blue',markerfacecoloralt='lightsteelblue',markeredgecolor='white',markeredgewidth=1,                    )fory,cap_styleinenumerate(CapStyle):ax.text(-0.5,y,cap_style.name,**text_style)ax.plot([0,5],[y]*2,linestyle=":",color='darkgrey')forx,thetainenumerate([0,10,15,20,30,45]):ax.plot(x,y,marker=MarkerStyle("1",transform=Affine2D().rotate_deg(theta),capstyle=cap_style),**marker_inner)ax.plot(x,y,marker=MarkerStyle("1",transform=Affine2D().rotate_deg(theta),capstyle=cap_style),**marker_outer)ax.text(x,3,f"{theta}°",**text_style)format_axes(ax)plt.show()

capstyle

fig,ax=plt.subplots()fig.suptitle('Marker JoinStyle',fontsize=14)fig.subplots_adjust(left=0.1)marker_colors=dict(markersize=35,markerfacecolor='tab:blue',markerfacecoloralt='lightsteelblue',markeredgecolor='brown',markeredgewidth=8)fory,join_styleinenumerate(JoinStyle):ax.text(-0.5,y,join_style.name,**text_style)ax.plot([0,5],[y]*2,linestyle=":",color='darkgrey')forx,thetainenumerate([0,10,15,20,30,45]):ax.plot(x,y,marker=MarkerStyle("*",transform=Affine2D().rotate_deg(theta),joinstyle=join_style),**marker_colors)ax.text(x,3,f"{theta}°",**text_style)format_axes(ax)plt.show()

joinstyle

list1 = [0, 1] #| x coordinateslist2 = [0, 0] #| y coordinatesp1 = [.5, 0] #| p1 stands for point1, the marker will be placed in this pointmarker1 = MarkerStyle(r'$|||$', transform=Affine2D().rotate_deg(45))plt.plot(list1, list2, 'o-k', linewidth = 1)plt.plot(p1[0], p1[1], 'k', marker = marker1)#T# show the resultsplt.show()

reproductor

Things that needs to be done:

  • Add modifiers such as (rotated -> returns new rotated instance, and other primitive transformations)
  • Add tests
  • Improve documentation

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [ N/A ] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@deep-jkldeep-jkl marked this pull request as ready for reviewSeptember 13, 2021 08:30
@deep-jkldeep-jkl mentioned this pull requestSep 14, 2021
7 tasks
Copy link
Member

@dstansbydstansby left a comment

Choose a reason for hiding this comment

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

I think this looks 👍 overall. I've left some comments and questions.

@jklymak
Copy link
Member

@deep-jkl this has developed a merge conflict. I don't think that should affect his reviewable it is, but will need to be fixed. It looks like some others have put some time into this, so feel free to ping them again if it is ready for a new look. Thanks for your patience!

deep-jkland others added16 commitsSeptember 21, 2021 23:36
Improvement was done in instantiating new instanceutilizing deep copy should preserve immutability ofMarkerStyle members (e.g. Path, or Transform).
Added, translated, scaled, and rotated methods with test.
Apply suggestion from@timhoffm, update lib/matplotlib/markers.pyCo-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@deep-jkl
Copy link
ContributorAuthor

@deep-jkl this has developed a merge conflict. I don't think that should affect his reviewable it is, but will need to be fixed. It looks like some others have put some time into this, so feel free to ping them again if it is ready for a new look. Thanks for your patience!

Thanks for the reminder, I hoped that you were just busy with the release.

@timhoffm@dstansby I have resolved conflict and comments, can you have a look on this PR?

@timhoffm
Copy link
Member

@deep-jkl thanks for following up. It'll be a couple of days before I can have a look.

deep-jkl reacted with thumbs up emoji

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

This is looking good to me. I made a bunch of suggestions, mostly to do w/ the doc strings...

deep-jkland others added3 commitsSeptember 28, 2021 09:26
Apply suggestions from@jklymak code reviewCo-authored-by: Jody Klymak <jklymak@gmail.com>
Apply suggestions from code reviewCo-authored-by: Jody Klymak <jklymak@gmail.com>
@deep-jkl
Copy link
ContributorAuthor

This is looking good to me. I made a bunch of suggestions, mostly to do w/ the doc strings...

Thanks for review, I have processed all the suggestions so far.

@jklymakjklymak added this to thev3.6.0 milestoneSep 28, 2021
Check for user style in get_cap(join)style is removed.This is also supported with two new tests.Additional test checks that get_transform returns combination ofsupplied and internal transformation.
Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

This looks good to me, and is an oft-requested feature that I think will make a lot of people happy!

@dstansbydstansby merged commitfcfea77 intomatplotlib:masterOct 5, 2021
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull requestOct 12, 2021
tacaswell pushed a commit that referenced this pull requestOct 20, 2021
@deep-jkldeep-jkl deleted the 19195-rotated-markers branchApril 13, 2022 18:31
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMay 6, 2023
When these Enum classes were added inmatplotlib#18544, they were supposed to befor documentation only. To that end,matplotlib#22055 was a followup that ensuredthat only the strings were exposed from the getter side.However, when user-supplied cap/join style were added inmatplotlib#20914, theywere only for the Enum type instead of the string, so correctly allowstrings here as well.Also, specifically type hint the return values as literals, as was doneinmatplotlib#25719.
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMay 6, 2023
When these Enum classes were added inmatplotlib#18544, they were supposed to befor documentation only. To that end,matplotlib#22055 was a followup that ensuredthat only the strings were exposed from the getter side.However, when user-supplied cap/join style were added inmatplotlib#20914, theywere only for the Enum type instead of the string, so correctly allowstrings here as well.Also, specifically type hint the return values as literals, as was doneinmatplotlib#25719.
@QuLogicQuLogic mentioned this pull requestMay 6, 2023
1 task
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMay 31, 2023
When these Enum classes were added inmatplotlib#18544, they were supposed to befor documentation only. To that end,matplotlib#22055 was a followup that ensuredthat only the strings were exposed from the getter side.However, when user-supplied cap/join style were added inmatplotlib#20914, theywere only for the Enum type instead of the string, so correctly allowstrings here as well.Also, specifically type hint the return values as literals, as was doneinmatplotlib#25719.
devRD pushed a commit to devRD/matplotlib that referenced this pull requestJun 5, 2023
When these Enum classes were added inmatplotlib#18544, they were supposed to befor documentation only. To that end,matplotlib#22055 was a followup that ensuredthat only the strings were exposed from the getter side.However, when user-supplied cap/join style were added inmatplotlib#20914, theywere only for the Enum type instead of the string, so correctly allowstrings here as well.Also, specifically type hint the return values as literals, as was doneinmatplotlib#25719.
melissawm pushed a commit to melissawm/matplotlib that referenced this pull requestJun 15, 2023
When these Enum classes were added inmatplotlib#18544, they were supposed to befor documentation only. To that end,matplotlib#22055 was a followup that ensuredthat only the strings were exposed from the getter side.However, when user-supplied cap/join style were added inmatplotlib#20914, theywere only for the Enum type instead of the string, so correctly allowstrings here as well.Also, specifically type hint the return values as literals, as was doneinmatplotlib#25719.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm left review comments

@jklymakjklymakjklymak approved these changes

@dstansbydstansbydstansby approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.6.0
Development

Successfully merging this pull request may close these issues.

5 participants
@deep-jkl@jklymak@timhoffm@dstansby@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp