8000 Annotation bbox clipping incorrect for `boxstyle='round'` Matplotlib >= 1.4.0 · Issue #4140 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Annotation bbox clipping incorrect for boxstyle='round' Matplotlib >= 1.4.0 #4140
Closed
@joferkington

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.

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

      0