-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
multiple imshow in figure are rendered as single image in svg, causing problems when clipping images #7151
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
Comments
By default, we composite images for output to vector graphics formats. I On Wed, Sep 21, 2016 at 5:39 AM, Luca notifications@github.com wrote:
|
cool! Many thanks and feel free to close the ticket! |
Is this really not a bug? Compositing is an optimization, but it shouldn't break things in alternate formats. |
I was wondering about this too. And this is true not only for svg (tested pdf and it is affected). |
probably should detect if the artist have non-trivial clipping and if so, opt them out of the optimization. The only place the compositing really helps you if you have many overlapping images, in the OPs case it might have been hurting (independent of the clipping bug!). |
Also of note is that there was a significant image infrastructure rewrite, so we should check what happens with 2.x and/or master. |
I think it goes way back, but I don't remember whether it was put in by JDH or by Mike. |
https://github.com/matplotlib/matplotlib/blame/v0.91.2/lib/matplotlib/axes.py |
In my opinion, given changing default behaviours is always risky, better documenting this might be a good starting point. My problem wasn't actually the behaviour of the svg compositing engine, but that I was not able to find the right switch to turn for solving the problem. Even if you google "image.composite_image" you see how much is difficult to get what it does. #2517 btw is the same. An example in the cookbook or similar with the right keywords, pointing to this and other issues, will definitively help. Or even add better info into the doc (?) said that a default option which creates discrepancies between format outputs maybe should be investigated better Thanks again everybody for this great library 👍 Luca |
…ics output Compositing is turned on by default in Matplotlib, which appears to cause images with multiple layers exported to PDF to merge these layers (see matplotlib/matplotlib#7151). Turn off this setting in the default theme.
This was fixed by #19375 in 3.5.0. |
I am on matplotlib 1.5.1 (but i suppose this is not related with this specific version)
This is probably a bug/limit of the svg export engine (maybe known?)
when multiple calls to imshow are made in the same figure and then saved in svg ALL the calls are joined into a single raster instead of having multiple (e.g. grouped) images in the svg file.
This make fail a simple test case like this. We call two times imshow to position two images in the figure, then we clip the two images with two different shapes. The problem is that in the svg the two imshow calls are joined in an unique raster, thus the clips are simply not created at all in the svg. Exporting each imshow() raster as a separated image in the svg, each with their clips, would probably solve the problem.
Is it possible or is a known limit?
if saved as png:

and as svg:

Code for generating these pictures (for a notebook):
many thanks for the wonderful work 👍
Luca
The text was updated successfully, but these errors were encountered: