SVG flip issue #1689

Closed
tkanmae opened this Issue Jan 20, 2013 · 2 comments

Projects

None yet

2 participants

@tkanmae
tkanmae commented Jan 20, 2013

#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')
@dmcdougall
Member

Thank @tkanmae for bringing this up again. I should have git bisected from the outset rather than fiddling with the SVG backend. Sorry for the wild goose chase.

I think your proposed solution of reverting 1c9f9b5 and doing a partial revert of 8c25664, keeping only the test cases, is the best option, provided all the tests pass after these changes.

See #1691 for the PR.

@tkanmae
tkanmae commented Jan 21, 2013

Thanks. Looks good to me.

@tkanmae tkanmae closed this Jan 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment