Skip to content

imsave ignores origin option #7656

Closed
Closed

Description

@cdeil

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

Activity

  1. added this to the milestone on Dec 21, 2016
  2. tacaswell commented on Dec 21, 2016

    @tacaswell
    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.

  3. tacaswell commented on Dec 21, 2016

    @tacaswell
    Member

    Exact work:

    • add check in AesImage.write_png for the origin state and flip color mapped imaged if needed.
  4. modified the milestones: , on Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions