8000 Keyword *interpolation* behaving improperly while saving to SVG with **savefig()** · Issue #12065 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Keyword *interpolation* behaving improperly while saving to SVG with **savefig()** #12065
Closed
@dabana

Description

@dabana

Bug report

Bug summary

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.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

fig, (axl, axr) = plt.subplots(1, 2)
# full green image
img = np.zeros((5, 5, 4))
img[...,1] = np.ones((5, 5))
# transparent above main diagonal
img[...,3] = np.tril(np.ones((5, 5), dtype=np.uint8))

axl.set_title('with keyword\ninterpolation="none"')
axr.set_title('WITHOUT keyword\ninterpolation')
axl.imshow(img, interpolation="none")
axr.imshow(img)

plt.savefig('interp_alpha_svg.svg')
plt.savefig('interp_alpha_png.png')

Actual outcome

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.

Expected outcome

This is the output you get when format is PNG.

interp_alpha_png

Matplotlib version

  • Operating system: Ubuntu 16.04 Bash on Windows10
  • Matplotlib version: 3.0.0rc1.post186+g5e01393
  • Matplotlib backend (print(matplotlib.get_backend())): agg
  • Python version: 3.5.2
  • Jupyter version (if applicable):
  • Other libraries:
    matplotlib installed from source

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0