Skip to content

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

Closed

Description

@joferkington

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.

Activity

  1. tacaswell commented on Feb 21, 2015

    @tacaswell
    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.

  2. added a commit that references this issue on Mar 2, 2015
    896880c
  3. added a commit that references this issue on Mar 14, 2015
    e7f3fb7
  4. added a commit that references this issue on Jun 20, 2015
    2a982fa
  5. added a commit that references this issue on Jul 20, 2015
    7829262
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions