Skip to content

Annotation bbox clipping incorrect for boxstyle='round' Matplotlib >= 1.4.0 #4140

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

Closed
joferkington opened this issue Feb 21, 2015 · 1 comment · Fixed by #4178
Closed

Annotation bbox clipping incorrect for boxstyle='round' Matplotlib >= 1.4.0 #4140

joferkington opened this issue Feb 21, 2015 · 1 comment · Fixed by #4178

Comments

@joferkington
Copy link
Contributor

Annotations using a bbox boxstyle of "round" have different (incorrect?) clipping behavior compared to a square boxstyle.

As an example, note that with matplotlib 1.4.0, the connector arrow extends inside the round box, while it is clipped for the square boxstyle. With earlier versions, both have the same clipping behavior.

import matplotlib.pyplot as plt
import matplotlib

def main():
    fig, ax = plt.subplots()
    ax.set(title='Matplotlib {}'.format(matplotlib.__version__))
    annotate(ax, 'Round')
    annotate(ax, 'Square')
    plt.show()

def annotate(ax, text):
    bbox = dict(fc='none')
    x, y = 0.1, 0.1

    if text == 'Round':
        bbox['boxstyle'] = 'round'
        y = 0.5

    ax.annotate(text, xy=(x, y), xytext=(50, 50), size=20,
                xycoords='data', textcoords='offset points',
                bbox=bbox,  arrowprops=dict(arrowstyle='->'))

main()

clip_mpl1 3

clip_mpl1 4 0

The problem persists up to and including the current HEAD, but newer versions also have the issue described in #4139 The two issues don't appear to be directly related.

@tacaswell
Copy link
Member

This is related to/duplicate of #4012. There is some subtle 'race' conditions with the fancy bounding boxes + fancy arrows. The root cause of this is the re-factoring of annotation for 1.4 (which I did).

I sunk a day into this leading up to 1.4.3 and did not make much headway.

efiring added a commit to efiring/matplotlib that referenced this issue Mar 2, 2015
Some comment and docstring typos are also fixed.
efiring added a commit to efiring/matplotlib that referenced this issue Mar 14, 2015
Some comment and docstring typos are also fixed.
efiring added a commit to efiring/matplotlib that referenced this issue Jun 20, 2015
Some comment and docstring typos are also fixed.
efiring added a commit to efiring/matplotlib that referenced this issue Jul 20, 2015
Some comment and docstring typos are also fixed.
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.

2 participants