Navigation Menu

Skip to content
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

Annotation text bbox calculated incorrectly in matplotlib>=1.4.3? #4139

Closed
joferkington opened this issue Feb 21, 2015 · 5 comments · Fixed by #4178
Closed

Annotation text bbox calculated incorrectly in matplotlib>=1.4.3? #4139

joferkington opened this issue Feb 21, 2015 · 5 comments · Fixed by #4178
Assignees
Milestone

Comments

@joferkington
Copy link
Contributor

Prior to matplotlib 1.4.3, text bounding boxes created with annotate did not include the connection arrow. Starting with 1.4.3 and continuing up to the current HEAD, the bbox includes the connection arrow.

As an example:

import matplotlib.pyplot as plt
import matplotlib

fig, ax = plt.subplots()

ax.annotate('Matplotlib {}'.format(matplotlib.__version__),
            xy=(0.1, 0.1), xytext=(50, 50), size=20,
            xycoords='data', textcoords='offset points',
            bbox=dict(alpha=0.5, fc='yellow'),
            arrowprops=dict(arrowstyle='->'))

plt.show()

mpl1 4 2

mpl1 4 3

mpl_github

This may be related to #4012?

@jenshnielsen
Copy link
Member

I think this is likely due to #4023 which was merged as 26c7d65

@tacaswell tacaswell added this to the Color overhaul milestone Feb 21, 2015
@tacaswell tacaswell added the Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Feb 21, 2015
@tacaswell
Copy link
Member

I agree with @jenshnielsen's diagnosis. Someplace a call to self.get_window_extent()needs to be changed toText.get_window_extent(self)`.

@cimarronm
Copy link
Contributor

It is related to #4023. The issue is that the Annotation draw method calls the Text draw method to draw the text box portion. Inside that, it calls bbox_artist from the patches modules which then calls get_window_extent of the instance.

@efiring
Copy link
Member

efiring commented Mar 1, 2015

There's even more: if boxstyle='square' is added to the bbox dictionary kwarg in the example, so that a FancyBboxPatch is drawn, then the filled region is correct, but the arrow is not clipped correctly.

@efiring efiring removed the Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Mar 1, 2015
@tacaswell
Copy link
Member

The clipping is related to #4012 I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants