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

text is not properly clipped in 1.2.1 #1885

Merged
merged 1 commit into from May 13, 2013
Merged

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Apr 8, 2013

matplotlib 1.2.1, python 2.7.3, OS X 10.8.3, TkAgg backend

Calling text() to render and then interactively panning the image, the resulting text is not properly clipped to the data window, and over flows it.

Code to reproduce:

import matplotlib.pyplot as plt

plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111)

t1 = ax.text(0.5, 0.2, 'no clip')
t2 = ax.text(0.5, 0.3, 'clipped', clip_on=True)

Now pan the text to the data window borders and watch the clipping.

Possible resolution:
So the bug appears to be that the initial bounding box for text is not set if 'clip_on' is not supplied as an arg.

t1.get_clip_on() == True
t1.get_clip_box() == None
t2.get_clip_on() == True
t2.get_clip_box() == TransformedBbox(...)

Toggling clip_on does not fix the problem.

@tacaswell
Copy link
Member

I can confirm this on python 2.7.4rc1, mpl 1.3.x, linux, Qt4Agg backend

… axes, regardless of the state of the clip_on kwarg, so that clip_on can be toggled after the fact
@mdboom
Copy link
Member

mdboom commented Apr 8, 2013

Confirmed. This is inconsistent with how other artists are handled -- they generally have the clip path assigned to them regardless of whether the clip is on or not so that it can later be toggled. I think the intent here is that text, unlike most other artists, defaults to having no clipping (which makes sense, since it's usually an axis label or an annotation, which one would not want to be clipped). However, since the clip path never gets set, it can't (easily) be turned on later.

Interestingly, this behavior goes way back in the annals of time to at least 909f34b (in 2007). @efiring: as another "old timer" here, do you know why it may have been implemented this way, or do you think this was probably just an easy-to-make bug due to the fact that text is not clipped by default?

@mdboom
Copy link
Member

mdboom commented Apr 8, 2013

The tests are failing trying to install inkscape -- I don't know if that's just transient or Travis no longer makes this work. @pelson, #1869

mdboom added a commit that referenced this pull request May 13, 2013
text is not properly clipped in 1.2.1
@mdboom mdboom merged commit 41315b6 into matplotlib:v1.2.x May 13, 2013
@mdboom mdboom deleted the clip-text branch August 7, 2014 13:54
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 this pull request may close these issues.

None yet

2 participants