Stretched norm behaviour broken on development `Matplotlib`
See original GitHub issueDescription
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: https://github.com/matplotlib/matplotlib/commit/146856b03e85aa4b1becdd89fe1628f98fed2a05, part of https://github.com/matplotlib/matplotlib/pull/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:
Image after Matplotlib change:
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:21 (10 by maintainers)
Top Results From Across the Web
Figure is stretched to window size · Issue #117 - GitHub
This is a pretty significant change from regular matplotlib behaviour. ... In a sense, figsize is always "set" with plt.rcParams['figure.figsize'] ...
Read more >Chapter 4. Visualization with Matplotlib - O'Reilly
Matplotlib is a multiplatform data visualization library built on NumPy arrays ... supported Matplotlib's development and greatly expanded its capabilities.
Read more >Changes to the default style — Matplotlib 3.6.2 documentation
This old behavior cannot be directly restored, but the density may be increased by repeating the hatch specifier. Fonts#. Normal text#. The default...
Read more >What's New In Python 3.7 — Python 3.11.1 documentation
Since this change breaks compatibility, the new behavior needs to be enabled on a per-module basis in Python 3.7 using a __future__ import:....
Read more >print in python on windows has broken tabulator - Stack Overflow
Image of strange tab behavior on Windows 7. Under Linux (Debian Stretch) it looks normal. Image of normal tab behavior on Linux. Any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To fix there’s nothing to do on the astropy side, but if astropy tests against Matplotlib dev a test should probably be added so this kind of bug is caught in the future - initially I found the bug in sunpy tests, and then isolated it to astropy.
@dstansby or @pllim 95% sure matplotlib/matplotlib#20327 will work with your Norm the way you expect. Sorry for the bother, and very very much appreciate you testing our dev branch!
EDIT: Fix repo link