Description
Bug summary
I am trying to improve some edge cases for plotting arrows in adjustText. Without going into details, sometimes I have to use ax.annotate to add arrows instead of directly using FancyArrowPatch. However in this case the arrows are not associated with the text objects and strike through them. I thought I could modify the arrow patch of the Annotation object to point to the corresponding Text object. The object appears to be set correctly, however this doesn't fix the clipping of the arrow! With a regular FancyArrowPatch this procedure works just as expected. Interestingly, if I update other properties (color) it works perfectly.
(As an aside, why do the two arrows have a different style in the example below?)
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib import patches
xytext = 0.2, 0.5
f, ax = plt.subplots()
ann = ax.annotate('', xy=(0.5, 0.6), xytext=xytext, arrowprops=dict(arrowstyle="->"))
ann_arrowpatch = ann.arrow_patch
print(ann_arrowpatch.patchA)
text = plt.text(xytext[0], xytext[1], 'Text', ha='center', va='center')
ann_arrowpatch.set_patchA(text)
print(ann_arrowpatch.patchA)
ann_arrowpatch.set_color('b')
arrowpatch = patches.FancyArrowPatch(posA=xytext, posB=(0.5, 0.4), arrowstyle="->", color='r')
ax.add_patch(arrowpatch)
print(arrowpatch.patchA)
arrowpatch.set_patchA(text)
print(arrowpatch.patchA)
Actual outcome
None
Text(0.2, 0.5, 'Text')
None
Text(0.2, 0.5, 'Text')
Expected outcome
Expect that the blue arrow is also clipped by the Text
Additional information
No response
Operating system
OS/X
Matplotlib Version
3.8.0
Matplotlib Backend
both inline and ipympl
Python version
3.11.7
Jupyter version
6.4.5
Installation
conda