X Tutup
Skip to content

imshow() does not interpret aspect/extent when interpolation='none' in svg output #7078

@golobor

Description

@golobor

imshow() ignores or misinterprets the aspect kwarg when interpolation='none'. The bug appears only in svg output, does not seem to be a problem in pdf or png output. The minimal code to reproduce the bug is below:

import numpy as np
import matplotlib
matplotlib.use('SVG')
import matplotlib.pyplot as plt

mat = np.ones((40,20))

plt.figure()
plt.subplot(121)
plt.imshow(
    mat,
    aspect=0.5,
    interpolation='nearest')
plt.subplot(122)
plt.imshow(
    mat,
    aspect=0.5,
    interpolation='none')
plt.savefig('/tmp/test.svg')

An image of the output is attached below. The issue also appears when I try to use extent kwarg instead of aspect, i.e. see below (if needed, I can attach an image produced by the second example):

plt.figure()
plt.subplot(121)
plt.imshow(
    mat,
    interpolation='nearest',
    extent=[0,20,20,0]

)
plt.subplot(122)
plt.imshow(
    mat,
    interpolation='none',
    extent=[0,20,20,0]
)
plt.savefig('/tmp/test2.svg')

svg_aspect_interpolation

My python environment is:
Ubuntu 16.04, anaconda python distribution, python 3.5.2, Matplotlib 1.5.1 (from conda)

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

      X Tutup