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

Fix #3647 [backport to 1.4.x] #3676

Merged
merged 2 commits into from Jan 12, 2015
Merged

Conversation

lennart0901
Copy link
Contributor

This fixes #3647, for me on the tkagg backend.
What still is strange is that the bug does not occur for e.g. cairo backend.

@tacaswell tacaswell added this to the v1.4.x milestone Oct 19, 2014
@tacaswell tacaswell changed the title Fix #3647 Fix #3647 [backport to 1.4.x] Oct 19, 2014
@@ -557,6 +557,9 @@ def draw(self, renderer):
self._set_gc_clip(gc)

if self._bbox:
self._bbox.update(dict(clip_box=self.clipbox,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done when the bounding box is created and when the various self.*clip* properties are done, not on every draw. This does fix the problem, but is rather inelegant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I do not understand why this is inelegant, compared to tracking the clip values in the dictionary all the time. _bbox is not the Rectangle itself or something but just a dict.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tacaswell: I'd appreciate, if you comment on that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this apparently fell off by radar.

If we are going to store equivalent state in two places we should not let them get out of sync with each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about making the combined dict a local variable, like

bbox_params = dict(self._bbox, clip_box=self.clipbox, ...

I'm somehow against syncing some state, that is internal and exactly determined by some other state.

@lennart0901
Copy link
Contributor Author

What do you mean with "[backport to 1.4.x]"?
before revising this in a sensible way, for me the question stays why the bug it does not occur with other backends.

It seems to me, that the difference between cairo and agg here is that clipping is reset with every set_clip_* in agg but in cairo set_clip_* is a noop when passed None. What should be the "correct" behaviour?

@tacaswell
Copy link
Member

The PR is against master, not the maintenance branch. The backport to 1.4.x is a note to who ever merges this to cherry-pick the merge commit back to 1.4.x so that this bug will be fixed in the next bug-fix release (1.4.x), not just on the next 1.Y release.

Can you provide line numbers? I am not familiar enough with this code (in either backend).

cc @mdboom

@lennart0901
Copy link
Contributor Author

for cairo it is at backend_cairo.py#L354
for agg there is no function set_clip_*. It uses the default ones backend_bases.py#L962. The attributes are reset when called with None

@tacaswell
Copy link
Member

From looking at the code, I would guess that the if not rectangle: return line is there so that the code below does not blow up and the removal of clearing of the clip rectangle by passing None was accidental. It might also be the case that the ability to remove the rectangle by passing None was also accidental...

git blame says that change to svg was added in 58c0054 by JDH merging a patch from Michiel (which I am assuming is @mdehoon).

The svg code was last touched in 2009, the backend_bases code was last touched in 2004(!).

@lennart0901
Copy link
Contributor Author

Of "svg", "pdf", "ps", "agg" and "cairo" only "cairo" does clip the bbox.
Only for the cairo-backend the drawing context is stored during new_gc

@tacaswell
Copy link
Member

Sorry, when I typed svg above I think I meant cairo.

@tacaswell tacaswell modified the milestones: v1.4.3, v1.4.x Dec 30, 2014
@tacaswell
Copy link
Member

This looks great! Thank you.

For future reference, there is no notification when commits get pushed (or if there is, please tell me where that setting is ;) ), if you leave a note it will get the attention of who ever you have been talking to on the thread (I get emails for comments on issues I have commented in, and gh notifications for all mpl issues that get comments).

For this bug, I think this is the correct solution (making sure clip information is propagated to all associated artists when it is set), however I think I will make a new issue re the inconsistent behavior of the GraphicsContextBase sub-classes.

tacaswell added a commit that referenced this pull request Jan 12, 2015
BUG : Fix #3647, text boxes are not clipped
@tacaswell tacaswell merged commit 53c2708 into matplotlib:master Jan 12, 2015
tacaswell added a commit that referenced this pull request Jan 13, 2015
BUG : Fix #3647, text boxes are not clipped
Conflicts:
	lib/matplotlib/tests/test_text.py

cherry-pick picked up too many tests in test_text.py
@tacaswell
Copy link
Member

backported as 76cd412

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.

text backgroundcolor not clipped in figures
2 participants