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

very high negative zorder breaks vector graphic rendering #1316

Merged
merged 1 commit into from Oct 1, 2012

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Sep 28, 2012

I have stumbled over a problem in vector graphic output with the pdf backend in combination with very high negative zorders (high positive values seem to be ok). Using the following example you see that for very high, negative zorder values the object gets visualized as bitmap.
I have verified this on matplotlib compiled from current master (Debian Squeeze, Python 2.6.6, with additional numpy 1.6.2).

import matplotlib
matplotlib.use("pdf")
import matplotlib.pyplot as plt
plt.plot([0, 1], [0, 1], zorder=-10000000)
plt.savefig("/tmp/zorder_bad.pdf")
plt.figure()
plt.plot([0, 1], [0, 1], zorder=-100)
plt.savefig("/tmp/zorder_ok.pdf")
plt.figure()
plt.plot([0, 1], [0, 1], zorder=1000000000000000)
plt.savefig("/tmp/zorder_ok2.pdf")

While this is obviously easy to circumvent (use reasonable zorder values ;)), I nevertheless think this should be fixed.

@dmcdougall
Copy link
Member

On Thu, Sep 27, 2012 at 3:12 PM, megies notifications@github.com wrote:

I have stumbled over a problem in vector graphic output with the pdf
backend in combination with very high negative zorders (high positive
values seem to be ok). Using the following example you see that for very
high, negative zorder values the object gets visualized as bitmap.
I have verified this on matplotlib compiled from current master (Debian
Squeeze, Python 2.6.6, with additional numpy 1.6.2).

import matplotlibmatplotlib.use("pdf")import matplotlib.pyplot as pltplt.plot([0, 1], [0, 1], zorder=-10000000)plt.savefig("/tmp/zorder_bad.pdf")plt.figure()plt.plot([0, 1], [0, 1], zorder=-100)plt.savefig("/tmp/zorder_ok.pdf")plt.figure()plt.plot([0, 1], [0, 1], zorder=1000000000000000)plt.savefig("/tmp/zorder_ok2.pdf")

While this is obviously easy to circumvent (use reasonable zorder values
;)), I nevertheless think this should be fixed.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1316.

Do you also see this behaviour saving a PDF with the Agg and Cairo backends?

Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

@megies
Copy link
Contributor Author

megies commented Sep 27, 2012

The same happens with agg backend. To test cairo i would have to make additional installs. I could do that if it is important to solve this.

@dmcdougall
Copy link
Member

On Thursday, September 27, 2012, megies wrote:

The same happens with agg backend. To test cairo i would have to make
additional installs. I could do that if it is important to solve this.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1316#issuecomment-8938036.

No that's ok. I jut wanted to know if the problem was with the PDF backend.
Since it also happens with AGG, I conclude that's not the case. Plus, I
have Cairo installed on my machine so I could do it myself if I need to.

I wonder if it happens with any vector format. Could you try the PS backend
and save a postscript file?

Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

@megies
Copy link
Contributor Author

megies commented Sep 27, 2012

I can confirm the problem with both AGG and PS backend saving to .ps files.

@dmcdougall
Copy link
Member

On Thu, Sep 27, 2012 at 4:21 PM, megies notifications@github.com wrote:

I can confirm the problem with both AGG and PS backend saving to .ps files.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1316#issuecomment-8939903.

Great, thanks.

Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

@mdboom
Copy link
Member

mdboom commented Sep 27, 2012

This is apparently a feature since 2009:

83b6a427

You need to call set_rasterization_zorder on the axes to some other value.

http://matplotlib.org/api/axes_api.html?highlight=rasterization_zorder#matplotlib.axes.Axes.set_rasterization_zorder

I'm not sure why zorder was overloaded in this way -- we may want to come up with a better solution for a future release.

@megies
Copy link
Contributor Author

megies commented Sep 27, 2012

Nice catch. Interesting. This sure is unexpected from (my) end user point of view.

@dmcdougall
Copy link
Member

@megies I'd like you to try one more test. Can you test with the following values of zorder:

zorder = -30001
zorder = -30000
zorder = -29999

@dmcdougall
Copy link
Member

@mdboom Beat me to it! :)

@dmcdougall
Copy link
Member

Technically this is resolved, but I'd rather leave it open because there is a better way to deal with the rasterisation zorder, though I'm not sure what the best way is.

@mdboom
Copy link
Member

mdboom commented Sep 27, 2012

I agree it's confusing to use the same property for two purposes. However, just adding a rasterize flag isn't the answer either -- in formats that don't support alpha blending, the rasterized stuff always has to be drawn first (hence the implicit connection between zorder and rasterizing). One easy solution might be to set the default rasterize_zorder to None (or -inf), in which case it's ignored. The user would then have to explicitly understand this feature and turn it on. That's probably a lot less surprising than how it works now.

@megies
Copy link
Contributor Author

megies commented Sep 27, 2012

Sounds good to me.

@dmcdougall
Copy link
Member

@mdboom That sounds better. Would you like me to implement that change as a pull request? Or would you like to do it?

@mdboom
Copy link
Member

mdboom commented Sep 27, 2012

Doesn't matter to me, but I probably won't get to it today.

@dmcdougall
Copy link
Member

@mdboom +1 on 8aca5e7. Looks like the tests pass, too.

dmcdougall added a commit that referenced this pull request Oct 1, 2012
very high negative zorder breaks vector graphic rendering
@dmcdougall dmcdougall merged commit cd84c99 into matplotlib:v1.2.x Oct 1, 2012
@mdboom mdboom deleted the zorder-fix branch March 3, 2015 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants