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

Clipping for OffsetBoxes #4466

Merged
merged 1 commit into from May 26, 2015
Merged

Conversation

has2k1
Copy link
Contributor

@has2k1 has2k1 commented May 25, 2015

  • Child Artists of DrawingArea now get clipped to the bounds of the parent

For reviewers

  • Also related to Offsetbox is another commit (or PR whichever is best) that will follow. This will include Offsetboxes in the tight_layout. In the tests it would make sense to cover invisible offsetboxes anchored to (in)visible axes. These tests would probably be sufficient for PR tight_layout ignores invisible axes #2008. Is O.K. to cherry-pick that PR?

@has2k1
Copy link
Contributor Author

has2k1 commented May 25, 2015

An example

examples/pylab_examples/anchored_artists.py
66:        self.da = DrawingArea(width, height, xdescent, ydescent, clip=True)

used an API term (clip=True) that was not explained in the docs and not implemented in the source. I got rid of the keyword (i.e an API change) because making it part of the implementation was not convincing. Would it mean, clip the DrawingArea (I could not think of a use case) or clip the children (which would have their own clip status).

Would this situation better be suited for a deprecation warning?

@has2k1 has2k1 force-pushed the fix-offsetbox-clipping branch 2 times, most recently from ff44733 to 2c54249 Compare May 25, 2015 04:00
@tacaswell tacaswell added this to the next point release milestone May 25, 2015
# Clipping has not been implemented in the OffesetBox family, so
# disable the clip flag for consistency. It can always be turned back
# on to zero effect.
self.set_clip_on(False)
Copy link
Member

Choose a reason for hiding this comment

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

probably should leave this.

@tacaswell
Copy link
Member

I think that a cilp on the offset box does make sense, the path of the DrawArea would first be clipped to it's clip path and then the artist would be clipped to that path. The use case I am thinking of is an OffsetBox which is half outside of an Axes, but I see the case that that should be a different PR.

This looks reasonable to me, but I would prefer to keep the clip kwarg to turn on/off the clipping of the children to the draw area and setting it to False by default. I think the change to clipping to the draw area by default is a much bigger API change than dropping the clip input.

was done with the `clip` argument. The object did not do any clipping
regardless of that parameter. Now the object can and does clip the child `Artists` if they are set to be clipped.

You can turn off the clipping using :method:`Artist.set_clip_on(False)`
Copy link
Member

Choose a reason for hiding this comment

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

Can you be more explicit about which artists need to be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No Artist needs to be changed. Maybe I will use a more explicit example.

Copy link
Member

Choose a reason for hiding this comment

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

By changed, I mean what artist do you call set_clip_on(False) on. It is not clear from this text that it should be on the children, not on the DrawingArea.

@has2k1
Copy link
Contributor Author

has2k1 commented May 25, 2015

On the clipping expectation, I had gone for consistency with children added to the Axes vs maintaining past code behaviour, provided that the tests passed.

@@ -0,0 +1,8 @@
'OffsetBox.DrawingArea' no longer accepts the 'clip' keyword argument
Copy link
Member

Choose a reason for hiding this comment

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

The title is no longer accurate. Should be 'OffsetBox.DrawingArea now respects clip' or something to that effect.

@tacaswell
Copy link
Member

That is a fair point and if we were adding these classes from scratch I think I would agree with your original implementation, but this code has been in the wild for a long time and maintaining current behavior is a very high priority.

Other than a few comments on the documentation, this looks good!

@has2k1 has2k1 force-pushed the fix-offsetbox-clipping branch 2 times, most recently from afef2b2 to 6ade0dd Compare May 26, 2015 01:35
- Child `Artists` of `DrawingArea` can now get clipped to the
  bounds of the parent
@has2k1
Copy link
Contributor Author

has2k1 commented May 26, 2015

It is fixed up.

Plus, are there any objections to Offsetboxes being considered in the tight_layout?

@tacaswell
Copy link
Member

I have no protests to including OffsetBoxes in tight layout considerations. My only concern is sinking too much time into the current tight_layout code when it might be better directed to sorting out a layout manager based on a linear constraint solver.

@@ -569,14 +570,16 @@ class DrawingArea(OffsetBox):
"""
The DrawingArea can contain any Artist as a child. The DrawingArea
has a fixed width and height. The position of children relative to
the parent is fixed.
the parent is fixed. The children can be clipped at the
Copy link
Member

Choose a reason for hiding this comment

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

super picky, extra space between 'be' and 'clipped'

Copy link
Member

Choose a reason for hiding this comment

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

I will take care of this. I want to extend this PR a bit and will just do it my self rather than explain what I want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I rebased and pushed already.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, it looks like I won the race condition on that and merged the previous version.

Copy link
Member

Choose a reason for hiding this comment

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

And if you have a change set, please open a PR.

On Mon, May 25, 2015 at 11:25 PM Hassan Kibirige notifications@github.com
wrote:

In lib/matplotlib/offsetbox.py
#4466 (comment):

@@ -569,14 +570,16 @@ class DrawingArea(OffsetBox):
"""
The DrawingArea can contain any Artist as a child. The DrawingArea
has a fixed width and height. The position of children relative to

  • the parent is fixed.
  • the parent is fixed. The children can be clipped at the

Well, I rebased and pushed already.


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/4466/files#r31002511.

tacaswell added a commit that referenced this pull request May 26, 2015
@tacaswell tacaswell merged commit 420f7c9 into matplotlib:master May 26, 2015
@tacaswell
Copy link
Member

Thanks!

@has2k1
Copy link
Contributor Author

has2k1 commented May 26, 2015

I already have a changeset for the tight_layout. On the linear constraint solver, has this been discussed elsewhere?

@tacaswell
Copy link
Member

The discussion is a bit scattered, most of it is at #1109

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