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

Add option of bounding box for PolygonSelector#21830

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
QuLogic merged 6 commits intomatplotlib:mainfromdstansby:polygon-box
Jan 5, 2022

Conversation

dstansby
Copy link
Member

@dstansbydstansby commentedDec 1, 2021
edited
Loading

PR Summary

This allows one to put a bounding box around a PolygonSelector, that can be used for resizing and moving (and eventually rotating) the selector points.

importmatplotlib.pyplotaspltfrommatplotlib.widgetsimportPolygonSelectorfig,ax=plt.subplots()sel=PolygonSelector(ax,lambda*args,**kwargs:None,draw_box=True)plt.show()
polygon.mov

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@dstansbydstansbyforce-pushed thepolygon-box branch 2 times, most recently from5847eda to4ac8e37CompareDecember 3, 2021 11:06
@dstansbydstansby added this to thev3.6.0 milestoneDec 3, 2021
@dstansby
Copy link
MemberAuthor

This should be ready for review now

Copy link
Member

@ericpreericpre left a comment

Choose a reason for hiding this comment

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

This works nicely, I made a couple of comments/suggestions.

Copy link

@dhomeierdhomeier left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and updates; I have tested this with a method inastropy/regions#406 that uses this new functionality and see that some early quirks have already been resolved!
A general issue with thatregions method, which connects a customPolygonSelector, is that creating a complete instance is somewhat tedious – adding the vertices and then triggering a redraw and finally marking the selector_selection_completed; for most of this I have not found public methods for the required operations. Having those, analogously toextents etc. inRectangleSelector would be a plus (but not necessary from this PR).

@dstansbydstansby marked this pull request as ready for reviewDecember 9, 2021 21:43
Copy link
Member

@ericpreericpre 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, it just need the test to be fixed!

Copy link
Member

@QuLogicQuLogic left a comment

Choose a reason for hiding this comment

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

I wonder if it should be calleddraw_bbox, or evendraw_bounding_box (since we seem to have pretty verbose names in widgets already.)

Comment on lines +1484 to +1409
event_sequence = (polygon_place_vertex(*verts[0]) +
polygon_place_vertex(*verts[1]) +
polygon_place_vertex(*verts[2]) +
polygon_place_vertex(*verts[3]) +
polygon_place_vertex(*verts[0]))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
event_sequence= (polygon_place_vertex(*verts[0])+
polygon_place_vertex(*verts[1])+
polygon_place_vertex(*verts[2])+
polygon_place_vertex(*verts[3])+
polygon_place_vertex(*verts[0]))
event_sequence= (
*polygon_place_vertex(*verts[0]),
*polygon_place_vertex(*verts[1]),
*polygon_place_vertex(*verts[2]),
*polygon_place_vertex(*verts[3]),
*polygon_place_vertex(*verts[0]),
)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I didn't do this since the rest oftest_widgets.py uses the+ notation. I'd be happy to put in a PR to change it all in one go though?

Update polygon every time bounding box is movedAllow box customisationRemove delPrevent rotation on polygon bounding boxFix line lengthCleanup transform logicDon't use dicts as keyword defaultsMinor doc fixes
Run exising polygon selector tests with draw_box=True
Trigger events on canvas in testTest doc fixes
@dstansby
Copy link
MemberAuthor

Thanks for reviewing. I changed the argument name todraw_bounding_box, but left the internal variables as_draw_box for simplicity. All other comments should be addressed. I also cleaned up the commit history a bit - sorry if this makes it a bit trickier to re-review...

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@QuLogicQuLogic merged commit37c9b04 intomatplotlib:mainJan 5, 2022
@dstansbydstansby deleted the polygon-box branchJanuary 5, 2022 22:34
@dstansbydstansby mentioned this pull requestJan 8, 2022
6 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ericpreericpreericpre approved these changes

@dhomeierdhomeierdhomeier requested changes

@QuLogicQuLogicQuLogic approved these changes

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

Successfully merging this pull request may close these issues.

4 participants
@dstansby@QuLogic@dhomeier@ericpre

[8]ページ先頭

©2009-2025 Movatter.jp