Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SVG flip issue #1689

Closed
Closed
@tkanmae

Description

@tkanmae

#1674 is not entirely fixed. I got a flipped svg using imshow() with origin='lower'. The snippet at the bottom reproduces the issue with the current master branch. This problem was introduced between v1.1.1 and v1.2.0rc3.

I dug the issue a bit deeper, and found that 1c9f9b5 introduced the issue. The commit seems a performance tweak for nearest neighbor scaling in a certain condition. Reverting 1c9f9b5 and 8c25664 fixes the issue.

I suggest to revert both commits, but to keep the test cases introduced in 8c25664. @mdboom, is this ok for you to revert 1c9f9b5 for now?

import matplotlib.pyplot as plt
import numpy as np

# Use default configuration.
plt.matplotlib.rcdefaults()

# Data
X, Y = np.meshgrid(np.arange(-5, 5, 1), np.arange(-5, 5, 1))
Z = np.sin(Y**2)

plt.rcParams['svg.image_noscale'] = False
plt.figure()
plt.imshow(Z, cmap='gray', origin='upper')
plt.savefig('upper.svg')

plt.rcParams['svg.image_noscale'] = True
plt.figure()
plt.imshow(Z, cmap='gray', origin='upper')
plt.savefig('upper_noscale.svg')

plt.rcParams['svg.image_noscale'] = False
plt.figure()
plt.imshow(Z, cmap='gray', origin='lower')
plt.savefig('lower.svg')

plt.rcParams['svg.image_noscale'] = True
plt.figure()
plt.imshow(Z, cmap='gray', origin='lower')
plt.savefig('lower_noscale.svg')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions