Skip to content

imshow() producing "inverted" colors since 3.0.3 #14293

Closed

Description

@cyclehome

Bug report

Bug summary

Since 3.0.3 imshow() produces "inverted" colors, instead of just including the image as is.

Code for reproduction

from PIL import Image
import matplotlib.pyplot as plt

img = Image.open("map.png")
plt.imshow(img)
plt.savefig("plot.png")

with this image as input:
map

Actual outcome
plot

Expected outcome
plot2
(until 3.0.2)

Matplotlib version

  • Operating system: win 7/10
  • Matplotlib version: 3.0.3, 3.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.7.2
  • Jupyter version (if applicable):
  • Other libraries: Pillow (6.0.0)

matplotlib installed from pip

Activity

  1. ImportanceOfBeingErnest commented on May 21, 2019

    @ImportanceOfBeingErnest
    Member

    Not sure if this was intentional in #13405, so marking as Release Crititical.

  2. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on May 21, 2019
  3. tacaswell commented on May 21, 2019

    @tacaswell
    Member

    This looks like a regression to me. I don't think the colors are inverted, I think one of the channels is getting color mapped....

  4. jklymak commented on May 21, 2019

    @jklymak
    Member

    Yeah basically we dropped support for PIL arrays, and we apparently never had tests for them...

  5. cyclehome commented on May 22, 2019

    @cyclehome
    Author

    ???
    3.1.0 documentation for Axes.imshow() says for the first parameter:

    X : array-like or PIL image

    However, if PIL support is dropped indeed, is this the intended way of doing it now:

    plt.imshow(np.array(list(img.convert('RGBA').getdata())).reshape(img.height, img.width, 4))

    Or is there a shorter way?

  6. jklymak commented on May 22, 2019

    @jklymak
    Member

    Sorry didn’t mean to say we meant to drop support, just that we did inadvertently.

  7. efiring commented on May 25, 2019

    @efiring
    Member

    @anntzer I suspect this is something related to your #13405, and you will quickly see how to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions