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
Saving as a pdf ignores set_clip_path when there is more than one of them. #18499
I am trying to plot some curves with variable width and opacity. To do this I first plot a background image with the correct color, which I then clip using patches.
It works perfectlty, except when I try to export the result as a PDF, where all clipping information is lost if I try to draw more than one curve. There is no problem when exporting to PNG or with the inline viewer.
I agree this is a bug, at least on Preview as well. Someone would have to dig into the pdf spec and figure out why this breaks. BTW, its worth noting that this works fine with just one curve, so Artist clipping works for PDF, but two clips are not allowed.
This actually affects all vector backends, and comes from image._draw_list_compositing_images, which completely fails to take image clipping into account (it only accounts for clipping of the parent axes/figure). My guess is that the simple solution is to just disable precompositing whenever custom clips are sets on the images, something along the lines of not_composite = ... or any(artist.get_clip_rectangle() is not None or artist.get_clip_path() is not None for artist in artists).
Activity
jklymak commentedon Sep 16, 2020
I agree this is a bug, at least on Preview as well. Someone would have to dig into the pdf spec and figure out why this breaks. BTW, its worth noting that this works fine with just one curve, so Artist clipping works for PDF, but two clips are not allowed.
anntzer commentedon Sep 16, 2020
This actually affects all vector backends, and comes from image._draw_list_compositing_images, which completely fails to take image clipping into account (it only accounts for clipping of the parent axes/figure). My guess is that the simple solution is to just disable precompositing whenever custom clips are sets on the images, something along the lines of
not_composite = ... or any(artist.get_clip_rectangle() is not None or artist.get_clip_path() is not None for artist in artists).Jhsmit commentedon Feb 3, 2021
After a few futile attempt to install matplotlib from source to try the PR I found a stackoverflow post with a solution for my issue: