WCSAxes¶
-
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.AxesThe main axes class that can be used to show world coordinates from a WCS.
Parameters: fig :
FigureThe 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, optionalThe WCS for the data. If this is specified,
transformcannot be specified.transform :
Transform, optionalThe transform for the data. If this is specified,
wcscannot be specified.coord_meta : dict, optional
A dictionary providing additional metadata when
transformis specified. This should include the keystype,wrap, andunit. Each of these should be a list with as many items as the dimension of the WCS. Thetypeentries should be one oflongitude,latitude, orscalar, thewrapentries should give, for the longitude, the angle at which the coordinate wraps (andNoneotherwise), and theunitshould give the unit of the coordinates asUnitinstances.transData :
Transform, optionalCan 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
xentry, oneyentry, 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 theWCS, 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 usingdata[:, :, 50].transpose())frame_class : type, optional
The class for the frame, which should be a subclass of
BaseFrame. The default is to use aRectangularFrameMethods Summary
draw(renderer[, inframe])get_coords_overlay(frame[, coord_meta])get_tightbbox(renderer)get_transform(frame)Return a transform from the specified frame to display coordinates. get_xlabel()get_ylabel()grid([b, axis, which])Plot gridlines for both coordinates. imshow(X, *args, **kwargs)Wrapper to Matplotlib’s imshow().plot_coord(*args, **kwargs)Plot SkyCoordorBaseCoordinateFrameobjects 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
Parameters: frame :
WCSorTransformor str- The
frameparameter can have several possible types: WCSinstance: 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 thisWCSAxesinstance. 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.Transforminstance: it is assumed to be a transform to the world coordinates that are part of the WCS used to instantiate thisWCSAxesinstance.'pixel'or'world': return a transformation that allows users to plot in pixel/data coordinates (essentially an identity transform) andworld(the default world-to-pixel transformation used to instantiate theWCSAxesinstance).'fk5'or'galactic': return a transformation from the specified frame to the pixel/data coordinates.BaseCoordinateFrameinstance.
- The
-
get_xlabel()[source] [edit on github]¶
-
get_ylabel()[source] [edit on github]¶
-
grid(b=None, axis='both', *, which='major', **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.Axesexcept that if no arguments are specified, the grid is shown rather than toggled.Parameters: 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
originwill be set tolower, 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
SkyCoordorBaseCoordinateFrameobjects onto the axes.The first argument to
plot_coord()should be a coordinate, which will then be converted to the first two parameters tomatplotlib.axes.Axes.plot. All other arguments are the same asmatplotlib.axes.Axes.plot. If not specified atransformkeyword argument will be created based on the coordinate.Parameters: coordinate :
SkyCoordorBaseCoordinateFrameThe coordinate object to plot on the axes. This is converted to the first two arguments to
matplotlib.axes.Axes.plot.See also
matplotlib.axes.Axes.plot- 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]¶
-