Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Imshow log normalization is looking different #30125

Closed as not planned
Closed as not planned
@XrioBtw

Description

@XrioBtw

Bug summary

Using norm = "log" normalization in imshow is looking different in matplotlib version 3.10.1 than in version 3.6.0, which might be related to Improve formatting of image values in cases of singular norms in version 3.9.2. The change is most likely intentional, as now it looks the same as if you manually log-transformed the image data. However, previously colours for the high number values were more pronounced, which was something I really liked. Can anyone show me how I can achieve the old log normalization behaviour via e.g. matplotlib.colors.LogNorm or similar?

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

img = np.array([460, 460, 580, 470, 460, 620, 460, 480, 900, 470, 480, 450, 450, 500, 450, 7300, 470, 470])
img = np.repeat(np.array([np.tile(img, 100)]), 1000, axis = 0).T

fig, (ax1, ax2) = plt.subplots(ncols = 2, nrows = 1)
ax1.imshow(img, cmap = "Blues", norm = "log")
ax2.imshow(np.log10(img), cmap = "Blues")
plt.show()

Actual outcome

Left image is what it looks like in matplotlib version 3.6.0, and the right image is what the left image looks like in matplotlib version 3.10.1 or if you manually log-transform the image.

Image

Expected outcome

I would like to achieve the left image (more vibrant colours for the higher values) with a more recent matplotlib version.

Operating system

Windows

Matplotlib Version

3.6.0

Matplotlib Backend

TkAgg

Python version

3.6.0

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions