You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adding colorbars to row subplots doesn't render the main plots when saving to .eps in 1.5.0 #5814
I upgraded to matplotlib 1.5.0 and ran into a potential bug involving colorbars, subplots and saving to .eps for which the only workaround I found was to downgrade back to 1.4.3 where the problem doesn't exist.
Essentially, the .eps output gets corrupted when multiple subplots in a row array (e.g. 1x2) have colorbars added to them. This results in a blank canvas on the main plots of all heatmaps but the first one in the .eps output, whereas the .pdf output works as intended.
These are the outputs (converted to .png, the top line in the .eps output in the second subplot is just an artefact from converting to .png):
.pdf:
.eps:
The problem persists when replacing pcolormesh with pcolor or imshow, using cax for colorbar axis instead of ax, changing colormaps, using row arrays of more subplots (for 1xn the last n-1 subplots have empty canvas), using gridspec to define subplots. The only thing that resolved this was to downgrade back to 1.4.3.
By opening the file in inkscape I can see that the issue is the bbox of the colorbar. It extends well beyond the colorbar it self and is plotted on top of the image to the right.
This comes from the fact that the Postscript file format doesn't support alpha blending. So when you have an image with transparent pixels, they come out as white.
I suppose the best thing to do here is to turn off the colorbar rasterization when using the Postscript backend... I'll try to work up a PR shortly.
This comes from the fact that the Postscript file format doesn't support
alpha blending. So when you have an image with transparent pixels, they
come out as white.
I suppose the best thing to do here is to turn off the colorbar
rasterization when using the Postscript backend... I'll try to work up a PR
shortly.
—
Reply to this email directly or view it on GitHub #5814 (comment)
.
This is going to be tricky to fix. The code that turns on rasterizing of colorbars is ignorant of the backend in use (and probably should remain so). The Postscript backend should probably be fixed so that when the rasterized layer contains alpha it falls back to not rasterizing. But I don't think it can figure that out before it actually rasterizes, so then it would have to store and play back the backend calls...
I'd really like to deprecate the Postscript backend -- there are fewer and fewer cases where Postscript is required but PDF can't be used instead. But I know there still a few tools and workflows that need Postscript, so that's probably not realistic yet.
Activity
jenshnielsen commentedon Jan 8, 2016
I can reproduce with 1.5.1rc1
By opening the file in inkscape I can see that the issue is the bbox of the colorbar. It extends well beyond the colorbar it self and is plotted on top of the image to the right.
jenshnielsen commentedon Jan 8, 2016
I think this is a bug in the rasterising code revealed by #4481
If I disable the rasterization it looks right:
mdboom commentedon Jan 8, 2016
This comes from the fact that the Postscript file format doesn't support alpha blending. So when you have an image with transparent pixels, they come out as white.
I suppose the best thing to do here is to turn off the colorbar rasterization when using the Postscript backend... I'll try to work up a PR shortly.
WeatherGod commentedon Jan 8, 2016
but, why is the bounding box for the colorbar not constrained?
On Fri, Jan 8, 2016 at 12:25 PM, Michael Droettboom <
notifications@github.com> wrote:
mdboom commentedon Jan 8, 2016
This is going to be tricky to fix. The code that turns on rasterizing of colorbars is ignorant of the backend in use (and probably should remain so). The Postscript backend should probably be fixed so that when the rasterized layer contains alpha it falls back to not rasterizing. But I don't think it can figure that out before it actually rasterizes, so then it would have to store and play back the backend calls...
I'd really like to deprecate the Postscript backend -- there are fewer and fewer cases where Postscript is required but PDF can't be used instead. But I know there still a few tools and workflows that need Postscript, so that's probably not realistic yet.
mdboom commentedon Jan 8, 2016
I think the code that "minimizes" the image is somehow broken...
WeatherGod commentedon Jan 8, 2016
How about we focus on fixing that first to minimize the impact this bug has?
On Fri, Jan 8, 2016 at 12:35 PM, Michael Droettboom <
notifications@github.com> wrote:
WeatherGod commentedon Jan 8, 2016
I winder if this problem exists also for pcolormesh plots, or if it is
specific to colorbar objects?
On Fri, Jan 8, 2016 at 12:41 PM, Benjamin Root ben.v.root@gmail.com wrote:
mdboom commentedon Jan 8, 2016
It's for anything that's rasterized (in this particular case, just the colorbars). I have a fix that I'll post shortly.
Fix matplotlib#5814