8000 initialise imshow with zero array has unexpected side effects · Issue #8467 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
initialise imshow with zero array has unexpected side effects #8467
@paulbrodersen

Description

@paulbrodersen

To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.

Bug report

Bug summary

When initialising AxesImage with numpy.zeros array, changing the image with set_data will have no effect on the displayed image (whereas the reverse is not true, i.e. initialise with non-zero arrays, change data to zero array).

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

plt.ion()

shape = (10,10)
Z = np.zeros(shape)
R = np.random.rand(*shape)

fig, ax = plt.subplots(1,1)
img1 = ax.imshow(R)
img1.set_data(Z) # shows zero array

fig, ax = plt.subplots(1,1)
img2 = ax.imshow(Z)
img2.set_data(R) # also displays zero array, ...

# ..., even though img.get_array() returns the correct array
print np.all(np.isclose(img2.get_array(), R))

Actual outcome

Two blue images.

Expected outcome

First figure blue, second figure showing randomly coloured pixels.

Matplotlib version

matplotlib 2.0.0 (installed via pip), python 2.7, Ubuntu 14.04 LTS

< 496A div class="CommentLoading-module__CommentLoadingContent--nb4e3">

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0