-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
[Bug]: ShrinkA and ShrinkB are ignored in ax.annotate(arrowprops=...) #27941
Comments
Ah doh ok so it turns out that it was working all along... its just that ShrinkA and ShrinkB are not fractional, they are in points. The following code works as expected shrinkB_values = np.array([0, 0.2, 0.4, 0.6, 0.8])*30
for shrinkB, x_anno in zip(shrinkB_values, annotation_x_values):
y_anno = np.sin(x_anno)
ax.annotate(
f'shrinkB={shrinkB}',
xy=(x_anno, y_anno),
xytext=(x_anno+1, y_anno+0.2),
arrowprops=dict(arrowstyle="->", shrinkB=shrinkB),
fontsize=10
) In the documentation it notes that the default value is |
Thanks for sorting that out @thehappycheese. I'm wondering if we could make this more obvious by updating the FancyArrowPatch docstring so it also mentions that these parameters are in points. |
Hi Ruth, thanks for taking the time to review! No worries :) I will create a PR to change this line in the docs shrinkA, shrinkB : float, default: 2
Shrinking factor of the tail and head of the arrow respectively. The word "factor" is misleading and could be replaced with |
Bug summary
Despite being documented [here] and (https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.annotate.html)
here, providing ShinkA and ShrinkB are ignored in annotations.
Code for reproduction
Actual outcome
All the arrows in the example above look the same; ShinkA/ShrinkB has no effect.
Expected outcome
Expected that the beginning / end of the arrows are moved toward or away from the source/target of the arrow.
By way of example, the simplearrow
shrink=
parameter (whenarrowstyle
is omitted) works as expected:Click here to expand code to reproduce the image below
However then I cant use the desired
arrowstyle='-->'
or control which end of the arrow is shrunk.Additional information
I have not been able to confirm, but I belive this comment from the documentation for
FancyArrowPatch
is the likely cause (link to doc source).My guess was that in the implementation of Axes.annotate, the
*path*
is provided?I cant find if that is happening though.
I think debugging near this use set_positions() might be a good starting point?
Operating system
windows
Matplotlib Version
3.8.3
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
Python 3.11.5
Jupyter version
VS Code Notebook (ipython Version: 8.17.2)
Installation
pip
The text was updated successfully, but these errors were encountered: