-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New anchored direction arrows #9078
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
Conversation
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.
Thanks for the incredibly thoroughly and well thought-out PR. I have some minor comments and a tip about the CI failure.
I think this could be a really cool feature.
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.
the space afer :class:
might be a problem (or might not, I'm not sure)
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.
Fixed
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.
lenght -> length
Please clarify if the length and width adjustments apply to both the line and the head
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.
Clarification attempted. Hope it is better now.
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 not sure why AppVeyor is complaining about SyntaxError: invalid escape sequence \o
right here
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.
Because it's complaining about the whole string and not the actual problem, which is on line 516.
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.
Works now with raw string removed.
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.
Because it's complaining about the whole string and not the actual problem, which is on line 516.
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.
This is a raw string inside a non-rawstring, so Python 3 is complaining.
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.
Use ...
for wrapping and align the wrapped line correctly:
>>> arrows = AnchoredDirectionArrows(ax.transAxes, '111', ... r'11$\overline{2}$')
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.
Fixed
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.
Use ...
for wrapping:
>>> from mpl_toolkits.axes_grid1.anchored_artists import \ ... AnchoredDirectionArrows
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.
Fixed
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.
Use ...
for wrapping here too; add spaces after commas.
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.
Fixed
Docstring fixes and clarifications are now committed. All tests are now fine.
Bump.
@idahj I'm going to try to get a second reviewer on this. so sorry it fell by the wayside.
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 see what the harm is putting this in the toolkit. OTOH, it would be nice to not have the toolkit after a while.
This needs a rebase before it can be merged.
ping @idahj this can be merged after a rebase. Can you do the rebase, or would you like a dev to push to this PR?
It should be OK now
Sorry, can you also squash the 17 commits?
What is the easiest way of doing that?
- backup your branch (assuming you are on your branch
git checkout -b backupbranch
) - checkout your branch again and
git log
. Look for the last entry that is not part of your changes, and note the hash... git rebase -i thehash
Only push if this isn't a huge error. If it makes a mess, then reset this branch to your backup branch:
git reset --hard backupbranch
and you will be back where you started.
wow, this is cool! Sorry this fell through the cracks.
commit a05a486 Merge: 6ec4f8f e751286 Author: Ida Hjorth <idahjorth@gmail.com> Date: Sun Apr 29 19:07:32 2018 +0200 Merge pull request #3 from magnunor/idahj_anchored_directionarrows Idahj anchored directionarrows commit e751286 Merge: 3ba79fb 6ec4f8f Author: Magnus Nord <magnunor@gmail.com> Date: Sun Apr 29 09:00:34 2018 +0200 Merge branch 'NEW_AnchoredDirectionArrows' of github.com:idahj/matplotlib into idahj_anchored_directionarrows commit 6ec4f8f Author: Ida <idahjorth@gmail.com> Date: Fri Aug 25 13:14:26 2017 +0100 AnchoredDirectionArrows: Docstring, what's new commit 19f4a38 Author: Ida <idahjorth@gmail.com> Date: Thu Aug 24 14:27:23 2017 +0100 AnchoredDirectionArrows: Demo docstring commit d024684 Author: Ida <idahjorth@gmail.com> Date: Thu Aug 24 14:09:52 2017 +0100 AnchoredDirectionArrows: Fix error commit 27b6bc5 Author: Ida <idahjorth@gmail.com> Date: Thu Aug 24 13:58:58 2017 +0100 AnchoredDirectionArrows: make variable not private commit c0762d2 Author: Ida <idahjorth@gmail.com> Date: Thu Aug 24 13:02:38 2017 +0100 AnchoredDirectionArrows: Add docstring in demo commit 88d04d0 Author: Ida <idahjorth@gmail.com> Date: Wed Aug 23 14:19:06 2017 +0100 AnchoredDirectionArrows: docstring, what's new commit efcca59 Author: Magnus Nord <Magnus.Nord@glasgow.ac.uk> Date: Wed Aug 23 13:31:32 2017 +0100 AnchoredDirectionArrows: add test which uses many of the arguments commit e200c44 Author: Magnus Nord <Magnus.Nord@glasgow.ac.uk> Date: Wed Aug 23 12:06:05 2017 +0100 AnchoredDirectionArrows: minor docstring changes commit b6b0ea2 Author: Ida <idahjorth@gmail.com> Date: Tue Aug 22 13:28:56 2017 +0100 AnchoredDirectionArrows: PEP8 commit 5fde65a Author: Ida <idahjorth@gmail.com> Date: Tue Aug 22 13:23:25 2017 +0100 AnchoredDirectionArrows: Add demo commit 23f7d5b Author: Ida <idahjorth@gmail.com> Date: Tue Aug 22 11:16:41 2017 +0100 AnchoredDirectionArrows: Add working unit test commit 459ae07 Author: Ida <idahjorth@gmail.com> Date: Tue Aug 22 10:37:44 2017 +0100 AnchoredDirectionArrow: first attempt unit test Currently not working commit f4ec0e2 Author: Ida <idahjorth@gmail.com> Date: Wed Aug 16 19:31:05 2017 +0100 Cleanup, bug fix, begin merge overlapping arrows commit 75e52b0 Author: Magnus Nord <magnunor@gmail.com> Date: Mon Aug 14 23:05:30 2017 +0100 AnchoredDirectionArrows: PEP8 fixes, and improve docstring commit 4fff775 Author: Ida <idahjorth@gmail.com> Date: Mon Aug 14 22:04:22 2017 +0100 Add AnchoredDirectionArrows class in axes_grid1
a05a486
to
4ba7f54
Compare
Commits are now squashed
Thanks so much @idahj Many appologies for the saga!
Uh oh!
There was an error while loading. Please reload this page.
This is a new mpl_toolkits class to easily create a pair of orthogonal arrows to indicate directions in a 2D-plot, such as this:
simple_example
This functionality is useful for users who want to represent projection images such as microscopy images, where orientation is important. One example is the below representation of an electron microscopy image, where the directions are vital for showing what projection of the crystal is imaged. Two arrows are needed, such that the viewer can know the angle of the projection.
40679_2017_42_fig5_html
:class:
~mpl_toolkits.axes_grid1.anchored_artists.AnchoredDirectionArrows
uses FancyArrowPatch, TextPath and PathPath to construct the arrow pair with labels , contained in an AnchoredOffsetbox.In the most simple example where all default values are used, only the arrow labels and the transform for the coordinate system is needed. But there are several optional parameters that can be used to tweak the direction indicator: loc, rotation of the arrow pair, dimensions, padding, separation, colors and font family.
Question 1: The user may want to create high contrast arrows with for example a light edge color and dark face color. As the AnchoredDirectionArrows consist of two FancyArrowPatch on top of each other, the edge of the top arrow will cross the bottom arrow face. In order to only have a visible edge around the outer edge of the pair, two AnchoredDirectionArrows can be constructed: The first arrow pair with edge, and the second arrow pair with no edge, but a face color without transparency. This solves the problem, but not very elegantly. Is there a robust way of merging the two FancyArrowPatches into one?
Example code:
demo_anchored_arrows