class astropy.visualization.wcsaxes.WCSAxes(fig, rect, wcs=None, transform=None, coord_meta=None, transData=None, slices=None, frame_class=<class 'astropy.visualization.wcsaxes.frame.RectangularFrame'>, **kwargs)[source] [edit on github]

Bases: matplotlib.axes.Axes

The main axes class that can be used to show world coordinates from a WCS.


fig : Figure

The figure to add the axes to

rect : list

The position of the axes in the figure in relative units. Should be given as [left, bottom, width, height].

wcs : WCS, optional

The WCS for the data. If this is specified, transform cannot be specified.

transform : Transform, optional

The transform for the data. If this is specified, wcs cannot be specified.

coord_meta : dict, optional

A dictionary providing additional metadata when transform is specified. This should include the keys type, wrap, and unit. Each of these should be a list with as many items as the dimension of the WCS. The type entries should be one of longitude, latitude, or scalar, the wrap entries should give, for the longitude, the angle at which the coordinate wraps (and None otherwise), and the unit should give the unit of the coordinates as Unit instances.

transData : Transform, optional

Can be used to override the default data -> pixel mapping.

slices : tuple, optional

For WCS transformations with more than two dimensions, we need to choose which dimensions are being shown in the 2D image. The slice should contain one x entry, one y entry, and the rest of the values should be integers indicating the slice through the data. The order of the items in the slice should be the same as the order of the dimensions in the WCS, and the opposite of the order of the dimensions in Numpy. For example, (50, 'x', 'y') means that the first WCS dimension (last Numpy dimension) will be sliced at an index of 50, the second WCS and Numpy dimension will be shown on the x axis, and the final WCS dimension (first Numpy dimension) will be shown on the y-axis (and therefore the data will be plotted using data[:, :, 50].transpose())

frame_class : type, optional

The class for the frame, which should be a subclass of BaseFrame. The default is to use a RectangularFrame

Methods Summary

draw(renderer[, inframe])
get_coords_overlay(frame[, coord_meta])
get_transform(frame) Return a transform from the specified frame to display coordinates.
grid([b, axis]) Plot gridlines for both coordinates.
imshow(X, *args, **kwargs) Wrapper to Matplotlib’s imshow().
plot_coord(*args, **kwargs) Plot SkyCoord or BaseCoordinateFrame objects onto the axes.
reset_wcs([wcs, slices, transform, coord_meta]) Reset the current Axes, to use a new WCS object.
set_xlabel(label[, labelpad])
set_ylabel(label[, labelpad])

Methods Documentation

draw(renderer, inframe=False)[source] [edit on github]
get_coords_overlay(frame, coord_meta=None)[source] [edit on github]
get_tightbbox(renderer)[source] [edit on github]
get_transform(frame)[source] [edit on github]

Return a transform from the specified frame to display coordinates.

This does not include the transData transformation


frame : WCS or Transform or str

The frame parameter can have several possible types:
  • WCS instance: assumed to be a transformation from pixel to world coordinates, where the world coordinates are the same as those in the WCS transformation used for this WCSAxes instance. This is used for example to show contours, since this involves plotting an array in pixel coordinates that are not the final data coordinate and have to be transformed to the common world coordinate system first.
  • Transform instance: it is assumed to be a transform to the world coordinates that are part of the WCS used to instantiate this WCSAxes instance.
  • 'pixel' or 'world': return a transformation that allows users to plot in pixel/data coordinates (essentially an identity transform) and world (the default world-to-pixel transformation used to instantiate the WCSAxes instance).
  • 'fk5' or 'galactic': return a transformation from the specified frame to the pixel/data coordinates.
  • BaseCoordinateFrame instance.
get_xlabel()[source] [edit on github]
get_ylabel()[source] [edit on github]
grid(b=None, axis='both', **kwargs)[source] [edit on github]

Plot gridlines for both coordinates.

Standard matplotlib appearance options (color, alpha, etc.) can be passed as keyword arguments. This behaves like matplotlib.axes.Axes except that if no arguments are specified, the grid is shown rather than toggled.


b : bool

Whether to show the gridlines.

imshow(X, *args, **kwargs)[source] [edit on github]

Wrapper to Matplotlib’s imshow().

If an RGB image is passed as a PIL object, it will be flipped vertically and origin will be set to lower, since WCS transformations - like FITS files - assume that the origin is the lower left pixel of the image (whereas RGB images have the origin in the top left).

All arguments are passed to imshow().

plot_coord(*args, **kwargs)[source] [edit on github]

Plot SkyCoord or BaseCoordinateFrame objects onto the axes.

The first argument to plot_coord() should be a coordinate, which will then be converted to the first two parameters to matplotlib.axes.Axes.plot. All other arguments are the same as matplotlib.axes.Axes.plot. If not specified a transform keyword argument will be created based on the coordinate.


coordinate : SkyCoord or BaseCoordinateFrame

The coordinate object to plot on the axes. This is converted to the first two arguments to matplotlib.axes.Axes.plot.

See also

This method is called from this function with all arguments passed to it.
reset_wcs(wcs=None, slices=None, transform=None, coord_meta=None)[source] [edit on github]

Reset the current Axes, to use a new WCS object.

set_xlabel(label, labelpad=1, **kwargs)[source] [edit on github]
set_ylabel(label, labelpad=1, **kwargs)[source] [edit on github]