Skip to content

Stretched norm behaviour broken on development Matplotlib #11800

@dstansby

Description

@dstansby

Description

Using a stretch norm is different on the development version of Matplotlib. The issue (see below for an example) bisects to the following change in Matplotlib: matplotlib/matplotlib@146856b, part of matplotlib/matplotlib#20054. It's not clear to me whether this is something that needs to be fixed in Matplotlib, or something needs changing in astropy.

Steps to Reproduce

import matplotlib.pyplot as plt
import numpy as np

from astropy.visualization import ImageNormalize, AsinhStretch

fig, ax = plt.subplots(figsize=(6, 2))
data = np.atleast_2d(np.linspace(0, 0.9, 10))
# data == [[0.  0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9]]
im = ax.imshow(data, norm=ImageNormalize(vmin=0, vmax=1, stretch=AsinhStretch()), cmap='prism')
fig.colorbar(im, orientation='horizontal')
plt.show()

Image before Matplotlib change:

before

Image after Matplotlib change:

after

Note how the colorbar is now stretched insetad of the ticks.

System Details

macOS-10.16-x86_64-i386-64bit
Python 3.9.1 (default, Dec 11 2020, 06:28:49)
[Clang 10.0.0 ]
Numpy 1.19.3
astropy 4.3.dev1547+gb52c40715
Scipy 1.5.4
Matplotlib 3.4.2.post948+g08f4629d91

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions