Data Visualization (astropy.visualization)

Introduction

astropy.visualization provides functionality that can be helpful when visualizing data. This includes a framework for plotting Astronomical images with coordinates with Matplotlib (previously the standalone wcsaxes package), functionality related to image normalization (including both scaling and stretching), smart histogram plotting, RGB color image creation from separate images, and custom plotting styles for Matplotlib.

Scripts

This module includes a command-line script, fits2bitmap to convert FITS images to bitmaps, including scaling and stretching of the image. To find out more about the available options and how to use it, type:

$ fits2bitmap --help

Reference/API

astropy.visualization Package

Functions

hist(x[, bins, ax, max_bins])

Enhanced histogram function

imshow_norm(data[, ax, imshow_only_kwargs])

A convenience function to call matplotlib’s matplotlib.pyplot.imshow function, using an ImageNormalize object as the normalization.

make_lupton_rgb(image_r, image_g, image_b[, …])

Return a Red/Green/Blue color image from up to 3 images using an asinh stretch.

quantity_support([format])

Enable support for plotting astropy.units.Quantity instances in matplotlib.

simple_norm(data[, stretch, power, asinh_a, …])

Return a Normalization class that can be used for displaying images with Matplotlib.

time_support(*[, scale, format, simplify])

Enable support for plotting astropy.time.Time instances in matplotlib.

Classes

AsinhStretch([a])

An asinh stretch.

AsymmetricPercentileInterval(…[, n_samples])

Interval based on a keeping a specified fraction of pixels (can be asymmetric).

BaseInterval()

Base class for the interval classes, which, when called with an array of values, return an interval computed following different algorithms.

BaseStretch()

Base class for the stretch classes, which, when called with an array of values in the range [0:1], return an transformed array of values, also in the range [0:1].

BaseTransform()

A transformation object.

CompositeStretch(transform_1, transform_2)

A combination of two stretches.

CompositeTransform(transform_1, transform_2)

A combination of two transforms.

ContrastBiasStretch(contrast, bias)

A stretch that takes into account contrast and bias.

HistEqStretch(data[, values])

A histogram equalization stretch.

ImageNormalize([data, interval, vmin, vmax, …])

Normalization class to be used with Matplotlib.

LinearStretch([slope, intercept])

A linear stretch with a slope and offset.

LogStretch([a])

A log stretch.

ManualInterval([vmin, vmax])

Interval based on user-specified values.

MinMaxInterval()

Interval based on the minimum and maximum values in the data.

PercentileInterval(percentile[, n_samples])

Interval based on a keeping a specified fraction of pixels.

PowerDistStretch([a])

An alternative power stretch.

PowerStretch(a)

A power stretch.

SinhStretch([a])

A sinh stretch.

SqrtStretch()

A square root stretch.

SquaredStretch()

A convenience class for a power stretch of 2.

ZScaleInterval([nsamples, contrast, …])

Interval based on IRAF’s zscale.

Class Inheritance Diagram

digraph inheritancef07e9d4871 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "AsinhStretch" [URL="../../api/astropy.visualization.AsinhStretch.html#astropy.visualization.AsinhStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An asinh stretch."]; "BaseStretch" -> "AsinhStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "AsymmetricPercentileInterval" [URL="../../api/astropy.visualization.AsymmetricPercentileInterval.html#astropy.visualization.AsymmetricPercentileInterval",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Interval based on a keeping a specified fraction of pixels (can be"]; "BaseInterval" -> "AsymmetricPercentileInterval" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseInterval" [URL="../../api/astropy.visualization.BaseInterval.html#astropy.visualization.BaseInterval",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for the interval classes, which, when called with an"]; "BaseTransform" -> "BaseInterval" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseStretch" [URL="../../api/astropy.visualization.BaseStretch.html#astropy.visualization.BaseStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for the stretch classes, which, when called with an array"]; "BaseTransform" -> "BaseStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseTransform" [URL="../../api/astropy.visualization.BaseTransform.html#astropy.visualization.BaseTransform",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A transformation object."]; "CompositeStretch" [URL="../../api/astropy.visualization.CompositeStretch.html#astropy.visualization.CompositeStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A combination of two stretches."]; "CompositeTransform" -> "CompositeStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseStretch" -> "CompositeStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CompositeTransform" [URL="../../api/astropy.visualization.CompositeTransform.html#astropy.visualization.CompositeTransform",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A combination of two transforms."]; "BaseTransform" -> "CompositeTransform" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ContrastBiasStretch" [URL="../../api/astropy.visualization.ContrastBiasStretch.html#astropy.visualization.ContrastBiasStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A stretch that takes into account contrast and bias."]; "BaseStretch" -> "ContrastBiasStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "HistEqStretch" [URL="../../api/astropy.visualization.HistEqStretch.html#astropy.visualization.HistEqStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A histogram equalization stretch."]; "BaseStretch" -> "HistEqStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ImageNormalize" [URL="../../api/astropy.visualization.mpl_normalize.ImageNormalize.html#astropy.visualization.mpl_normalize.ImageNormalize",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Normalization class to be used with Matplotlib."]; "Normalize" -> "ImageNormalize" [arrowsize=0.5,style="setlinewidth(0.5)"]; "LinearStretch" [URL="../../api/astropy.visualization.LinearStretch.html#astropy.visualization.LinearStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A linear stretch with a slope and offset."]; "BaseStretch" -> "LinearStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "LogStretch" [URL="../../api/astropy.visualization.LogStretch.html#astropy.visualization.LogStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A log stretch."]; "BaseStretch" -> "LogStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ManualInterval" [URL="../../api/astropy.visualization.ManualInterval.html#astropy.visualization.ManualInterval",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Interval based on user-specified values."]; "BaseInterval" -> "ManualInterval" [arrowsize=0.5,style="setlinewidth(0.5)"]; "MinMaxInterval" [URL="../../api/astropy.visualization.MinMaxInterval.html#astropy.visualization.MinMaxInterval",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Interval based on the minimum and maximum values in the data."]; "BaseInterval" -> "MinMaxInterval" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Normalize" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="A class which, when called, linearly normalizes data into the"]; "PercentileInterval" [URL="../../api/astropy.visualization.PercentileInterval.html#astropy.visualization.PercentileInterval",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Interval based on a keeping a specified fraction of pixels."]; "AsymmetricPercentileInterval" -> "PercentileInterval" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PowerDistStretch" [URL="../../api/astropy.visualization.PowerDistStretch.html#astropy.visualization.PowerDistStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An alternative power stretch."]; "BaseStretch" -> "PowerDistStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PowerStretch" [URL="../../api/astropy.visualization.PowerStretch.html#astropy.visualization.PowerStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A power stretch."]; "BaseStretch" -> "PowerStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SinhStretch" [URL="../../api/astropy.visualization.SinhStretch.html#astropy.visualization.SinhStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A sinh stretch."]; "BaseStretch" -> "SinhStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SqrtStretch" [URL="../../api/astropy.visualization.SqrtStretch.html#astropy.visualization.SqrtStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A square root stretch."]; "BaseStretch" -> "SqrtStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SquaredStretch" [URL="../../api/astropy.visualization.SquaredStretch.html#astropy.visualization.SquaredStretch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A convenience class for a power stretch of 2."]; "PowerStretch" -> "SquaredStretch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ZScaleInterval" [URL="../../api/astropy.visualization.ZScaleInterval.html#astropy.visualization.ZScaleInterval",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Interval based on IRAF's zscale."]; "BaseInterval" -> "ZScaleInterval" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

astropy.visualization.mpl_normalize Module

Normalization class for Matplotlib that can be used to produce colorbars.

Functions

simple_norm(data[, stretch, power, asinh_a, …])

Return a Normalization class that can be used for displaying images with Matplotlib.

imshow_norm(data[, ax, imshow_only_kwargs])

A convenience function to call matplotlib’s matplotlib.pyplot.imshow function, using an ImageNormalize object as the normalization.

Classes

ImageNormalize([data, interval, vmin, vmax, …])

Normalization class to be used with Matplotlib.

Class Inheritance Diagram

digraph inheritance953d37714d { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ImageNormalize" [URL="../../api/astropy.visualization.mpl_normalize.ImageNormalize.html#astropy.visualization.mpl_normalize.ImageNormalize",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Normalization class to be used with Matplotlib."]; "Normalize" -> "ImageNormalize" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Normalize" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="A class which, when called, linearly normalizes data into the"]; }