8000 Using CenterNorm in imshow with a given halfrange does display data when not displaying the colorbar · Issue #25523 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Using CenterNorm in imshow with a given halfrange does display data when not displaying the colorbar #25523
Closed
@TomFD

Description

@TomFD

Problem description

A simple plot is empty under the following cirumstances:

Use the standard example:

import matplotlib.pyplot as plt
from matplotlib.colors import CenteredNorm
import numpy as np

data = np.random.random((100, 100))

fig, ax = plt.subplots()
im = ax.imshow(data, norm=CenteredNorm(halfrange=0.2))
fig.colorbar(im)

plt.show(block=True)

If you now delete the line fig.colorbar(im), the data is not shown (white content). If you then remove halfrange=0.2 the data appears again. This is unexpected as one needs to see the data even by giving a certain halfrange and without the colorbar.

Standard (expected) outcome

image

Outcome without colorbar line

image

System

Microsoft Windows [Version 10.0.25300.1000]
VS Code 1.76.2
Python 3.10.8

Tested as python script and Jupyter notebook
@jpmattern

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0