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
Keyword *interpolation* behaving improperly while saving to SVG with **savefig()** #12065
When saving an interpolated rbga image to SVG format, the output depends whether the keyword interpolation as been omitted or it has been put to none (interpolation="none"). This should not be the case. It should produce an UN-interpolated image in both case. We do not see this behavior with the other formats, PNG for instance.
Github does not support SVG so here is my description. The left image, with interpolation="none", looks interpolated (smoothed edges), but the right image, WITHOUT the interpolation keyword, has sharp edges.
I think this is basically an instance of #10112: the uniniterpolated image is stored as a big 5x5 image and svg renderers interpolate it by default; the non-interpolated image is upsampled (in nearest mode) to a much larger number of pixels.
Okai so if I understand correctly, if we want to fix this issue we need to make sure that a large UPsampled image gets sent to the SVG renderer with interpolation="none" as well as WITHOUT the interpolation keyword (which is already the case).
IF "specifying interpolation=none" and "omitting interpolation" behaving differently IS the intended behavior
THEN, oh well... close this issue...
OTHERWISE we have two options:
A) We should make sure that a NON-sampled image gets sent to the SVG renderer with interpolation="none" (which is already the case) as well as WITHOUT the interpolation keyword. That way the SVG render takes care of doing whatever it wants.
B) We should make sure that the SVG renderer always does a descent job by sending it an UP-sampled image with interpolation="none" as well as WITHOUT the interpolation keyword (which is already the case).
For the Agg, ps and pdf backends, interpolation = 'none' works well when a big image is scaled down, while interpolation = 'nearest' works well when a small image is scaled up.
So apparently some difference is expected between the two.
If interpolation is None, default to rc image.interpolation. See also the filternorm and filterrad parameters. If interpolation is 'none', then no interpolation is performed on the Agg, ps and pdf backends. Other backends will fall back to 'nearest'.
So it IS the intended behavior. In the doc, should we specify:
that the SVG backend will not perform any interpolation either using interpolation = 'none'
that rc image.interpolation is the same as 'nearest'
that SVG renders (such as browsers) might perform interpolation on SVG images.
Activity
anntzer commentedon Sep 7, 2018
I think this is basically an instance of #10112: the uniniterpolated image is stored as a big 5x5 image and svg renderers interpolate it by default; the non-interpolated image is upsampled (in nearest mode) to a much larger number of pixels.
dabana commentedon Sep 7, 2018
Okai so if I understand correctly, if we want to fix this issue we need to make sure that a large UPsampled image gets sent to the SVG renderer with interpolation="none" as well as WITHOUT the interpolation keyword (which is already the case).
anntzer commentedon Sep 7, 2018
No, we want to tell the svg renderer not to perform resampling itself, as explained in #10112.
dabana commentedon Sep 7, 2018
Just so I get this clear, specifying interpolation="none" and omitting interpolation behaving differently IS the intended behavior?
anntzer commentedon Sep 7, 2018
Good point, that I don't know...
dabana commentedon Sep 7, 2018
IF "specifying interpolation=none" and "omitting interpolation" behaving differently IS the intended behavior
THEN, oh well... close this issue...
OTHERWISE we have two options:
A) We should make sure that a NON-sampled image gets sent to the SVG renderer with interpolation="none" (which is already the case) as well as WITHOUT the interpolation keyword. That way the SVG render takes care of doing whatever it wants.
B) We should make sure that the SVG renderer always does a descent job by sending it an UP-sampled image with interpolation="none" as well as WITHOUT the interpolation keyword (which is already the case).
A or B is the question now...
dabana commentedon Sep 7, 2018
I vote for B
ImportanceOfBeingErnest commentedon Sep 7, 2018
Just that we know what the issue is, here is the output of the code when the svg is opened in inkscape 0.91:
(Maybe worth noting that inkscape 0.49 shows no difference between the two subplots)
ImportanceOfBeingErnest commentedon Sep 7, 2018
Equally worth noting that there is a difference between
Noneand"none"(Noneis the image.interpolation rc parameter, which defaults to"nearest").The interpolation_methods demo states:
So apparently some difference is expected between the two.
dabana commentedon Sep 8, 2018
From the imshow() documentation:
So it IS the intended behavior. In the doc, should we specify:
image.interpolationis the same as 'nearest'timhoffm commentedon Sep 9, 2018
The docstring has already changed a bit in the current master:
https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.imshow.html
Issue 2 is already handled. 1 an 3 remain open. You are welcome to provide a PR to clarify the SVG handling.
clarifications to **im_show()** doc regarding issues matplotlib#12065 …
Update backend_svg.py