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

Appearance settings

[Bug]: setting patchA of Annotation.arrow_patch has no effect #28316

Copy link
Copy link
Open
@Phlya

Description

@Phlya
Issue body actions

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')

image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.