-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add an arrow tutorial #11223
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
Add an arrow tutorial #11223
Conversation
I think this rather qualifies as example than as tutorial? There is also already the annotation_demo example and the annotations tutorial. So I wonder in how far they are overlapping or not. Independent of that, there should be links in between them. |
Or, if this is to be the "definitive arrow guide" as a tutorial, the following things should be considered:
|
Here we show three use cases for plotting arrows, depending on whether the | ||
head or anchor points need to be fixed in data or display space: | ||
|
||
1. Head fixed in display space, anchor points fixed in data space |
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.
"Head shape" would be better than just "head" because the head anchor does move around so I found this confusing.
|
||
1. Head fixed in display space, anchor points fixed in data space | ||
2. Head and anchor points fixed in display space | ||
3. Head and anchor points fixed in data space |
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'd say arrow patch defined in purely in data space. This is really radically different than the others...
Arrow guide | ||
=========== | ||
|
||
Adding arrows to plots Matplotlib. |
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.
OK, this is really adding Arrow patches to matplotlib.
|
||
Arrows consist of a head (and possibly a tail) and a stem drawn between a | ||
start point and and end point, called 'anchor points' from now on. | ||
Here we show three use cases for plotting arrows, depending on whether the |
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.
Suggest adding: Usually we want the head shape to be drawn in physical space and not scale as the figure or axes limits change analgous to how text annotations don't change size. Conversely, we often want the anchor points to move either with the data limits of the axes, or be at a position relative to the axes or figure bounds.
... or something more eloquent but explaining why arrows are a hard shape to just draw...
|
||
|
||
############################################################################### | ||
# Head fixed in display space and anchor points fixed in data space |
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.
Head shape
axs[1].set_ylim(0, 2) | ||
|
||
############################################################################### | ||
# Head and anchor points fixed in display space |
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.
Head Shape
|
||
|
||
############################################################################### | ||
# Head and anchor points fixed in data space |
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.
Head shape and anchor points drawn in data space...
# | ||
# In this case we use `.patches.Arrow` | ||
# | ||
# Note that when the axis limits are changed, the arrow shape and location |
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.
Umm, I'd have something in here about why we would ever want to do this....
I agree there is lots more that could go in here, but for now its an improvement. I do think a link to the Annotations demo and tutorial would be nice. But adding an arrow and an annotation are different, and I for one appreciate adding just the arrow documention. |
Thanks for the feedback! I agree that as this stands it's more like an example, so I've put it in examples. I don't have time to expand this at the moment, but I think is an improvement as is that is worth going in. All of your suggestions for expanding this are great @ImportanceOfBeingErnest ; maybe it would be best to put them in a new issue that someone could work on in the future? |
Pushed an underline change to your PR.... I'll merge this once it passes. Indeed it doesn't cover everything, but is a good start/placeholder for further efforts. |
Thanks @dstansby Other folks - more than welcome to open new PRs with additional tutorial material! |
Fixes #11219
This is quite short, but I think illustrates how to plot arrows with various display/data space options. All suggestions and comments welcome!