imshow_norm¶
-
astropy.visualization.mpl_normalize.
imshow_norm
(data, ax=None, imshow_only_kwargs={}, **kwargs)[source]¶ A convenience function to call matplotlib’s
matplotlib.pyplot.imshow
function, using anImageNormalize
object as the normalization.Parameters: data : 2D or 3D array_like - see
imshow
The data to show. Can be whatever
imshow
andImageNormalize
both accept.ax : None or
Axes
, optionalIf None, use pyplot’s imshow. Otherwise, calls
imshow
method of the supplied axes.imshow_only_kwargs : dict, optional
Arguments to be passed directly to
imshow
without first tryingImageNormalize
. This is only for keywords that have the same name in bothImageNormalize
andimshow
- if you want to set theimshow
keywords only, supply them in this dictionary.kwargs : dict, optional
All other keyword arguments are parsed first by the
ImageNormalize
initializer, then toimshow
.Returns: result : tuple
A tuple containing the
AxesImage
generated byimshow
as well as theImageNormalize
instance.Notes
The
norm
matplotlib keyword is not supported.Examples
import numpy as np import matplotlib.pyplot as plt from astropy.visualization import (imshow_norm, MinMaxInterval, SqrtStretch) # Generate and display a test image image = np.arange(65536).reshape((256, 256)) fig = plt.figure() ax = fig.add_subplot(1, 1, 1) im, norm = imshow_norm(image, ax, origin='lower', interval=MinMaxInterval(), stretch=SqrtStretch()) fig.colorbar(im)