Skip to content

The SuperCuts patch! Clipping done right. #290

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

Merged
merged 1 commit into from
May 5, 2016

Conversation

WeatherGod
Copy link
Member

* Clip just about all artists to map limbs,
  and clip the map limbs to the plot area
@WeatherGod
Copy link
Member Author

attn @cpaulik

@guziy
Copy link
Contributor

guziy commented May 5, 2016

@WeatherGod: Nice one)) I was looking at it myself, but dropped because could not see why it was happening.

Cheers

@WeatherGod
Copy link
Member Author

Our unit tests wouldn't cover this, so I ran the "run_all.py" script in the examples directory. Not only did I check to make sure all of the examples ran correctly, I also would pan all of the interactive plots. With this change, not only does imshow() for robinson projection and others now work, but I can now confirm that all other artists are now clipped to the map, and to the plot area, even when panning/zooming. Of particular concern was the parallels and meridians, the coastlines and other such items, which all works fine now.

Technically speaking, this is a behavior change, as the plotting area was often not used for clipping. However, it was very inconsistent whether or not an artist was clipped or not, so I considered that a bug and made everything (except ticklines and tick labels) clipped to the plotting area.

@sebhahn
Copy link

sebhahn commented May 5, 2016

I just quickly tested your PR and something seems to be wrong with the projection. However, let me check if this is a problem on my side, since I've no general minimal example at hand.

test

This was referenced May 5, 2016
@sebhahn
Copy link

sebhahn commented May 5, 2016

ok just figured out that it was my fault. I had to use m.transform_scalar(). Before, I used the image directly in imshow() and not the transformed one. Thanks again for fixing this issue!

test2

@WeatherGod
Copy link
Member Author

Thanks for confirming the fix! I am going to go ahead and merge this in.

If all goes well (personal schedule-wise), I hope to be cutting a release candidate either this weekend or next weekend. An additional goal is to have the release candidate available on pypi.

@WeatherGod WeatherGod merged commit df533d4 into matplotlib:master May 5, 2016
@sebhahn
Copy link

sebhahn commented May 5, 2016

@WeatherGod, not sure if this is related to this, but is there any option to set the thickness of the map boundary, it looks like the top/bottom line are much thinner than the left/right one. Looking closely to the line at the equator makes it also a little bit thinner. I know this is just a facial issue, but maybe you know how to control this?

@WeatherGod
Copy link
Member Author

Actually, this is an inadvertent side-effect of this recent change. The map limbs are now clipped to the plotting area, which solves a lot of other problems. However, because of the way the limbs are drawn, they go all the way to the edge of the plot area, and get "trimmed" by the clipping.

I am not exactly sure how we should address this. I'll have to think about this one.

@WeatherGod WeatherGod deleted the cliplimbs branch May 5, 2016 21:19
@sebhahn
Copy link

sebhahn commented May 5, 2016

Yes, it seems like the lines are trimmed and therefore appear less thick at the top/bottom and the equator. A buffer zone around the lines/clipping area may help?

@WeatherGod
Copy link
Member Author

Easier said than done, I think. The problem is that the map limbs are done in data coordinates. So, defining a buffer zone around that in points is tricky. Also, I am not sure if there might be other implications as well (thinking of rotpol and such).

@WeatherGod
Copy link
Member Author

Hmmm, think I just came across another possible side-effect of this set of changes. It apparently has been assumed that set_axes_limits() would be the last method called in each of the plotting methods, so if one was in interactive mode, it would trigger a draw. However, now, that draw would happen before clipping. This might not be terrible, though, with the changes in the interactive mode for matplotlib v1.5, which should trigger another redraw right after the clipping, I think.

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.

3 participants