Skip to content

imsave ignores origin option #7656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cdeil opened this issue Dec 21, 2016 · 2 comments
Closed

imsave ignores origin option #7656

cdeil opened this issue Dec 21, 2016 · 2 comments
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Milestone

Comments

@cdeil
Copy link
Contributor

cdeil commented Dec 21, 2016

For me, the imsave option origin="lower" is silently ignored when saving to PNG.

If I execute this script, the resulting two images are identical:

import numpy as np
from matplotlib.image import imsave

image = np.arange(30*20).reshape((20, 30))
imsave('lower.png', image, origin='lower')
imsave('upper.png', image, origin='upper')

Is this a MPL bug?


Version info: Python 3.5 as well as Numpy and MPL installed via macports, then MPL 2.0.0rc2 via pip in user site-packages, i.e. this is with MPL 2.0.0rc2.


lower.png is here:

lower


upper.png is here:

upper

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Dec 21, 2016
@tacaswell
Copy link
Member

import numpy as np
from matplotlib.image import imsave

image = np.arange(30*20).reshape((20, 30))

fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.imshow(image, origin='lower')
ax2.imshow(image, origin='upper')

Fortunately this is a bug in imsave and not in Axes.imshow
so

imsave is efficient and skips the standard draw machirary (and just uses AxesImage.write_png) which ignores the origin state.

@tacaswell tacaswell added Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues new-contributor-friendly labels Dec 21, 2016
@tacaswell
Copy link
Member

tacaswell commented Dec 21, 2016

Exact work:

  • add check in AesImage.write_png for the origin state and flip color mapped imaged if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
Projects
None yet
Development

No branches or pull requests

2 participants