FITSFigure¶
- class aplpy.FITSFigure(data, hdu=0, figure=None, subplot=(1, 1, 1), downsample=False, north=False, convention=None, dimensions=[0, 1], slices=[], auto_refresh=None, **kwargs)[source]¶
Bases:
aplpy.layers.Layers
,aplpy.regions.Regions
Create a FITSFigure instance.
This class is a wrapper around the Astropy WCSAxes class and provides the same API as historical versions of APLpy.
- Parameters
- datasee below
The FITS file to open. The following data types can be passed:
string astropy.io.fits.PrimaryHDU astropy.io.fits.ImageHDU astropy.wcs.WCS np.ndarray RGB image with AVM meta-data
- hduint, optional
By default, the image in the primary HDU is read in. If a different HDU is required, use this argument.
- figure~matplotlib.figure.Figure, optional
If specified, a subplot will be added to this existing matplotlib figure() instance, rather than a new figure being created from scratch.
- subplottuple or list, optional
If specified, a subplot will be added at this position. If a tuple of three values, the tuple should contain the standard matplotlib subplot parameters, i.e. (ny, nx, subplot). If a list of four values, the list should contain [xmin, ymin, dx, dy] where xmin and ymin are the position of the bottom left corner of the subplot, and dx and dy are the width and height of the subplot respectively. These should all be given in units of the figure width and height. For example, [0.1, 0.1, 0.8, 0.8] will almost fill the entire figure, leaving a 10 percent margin on all sides.
- downsampleint, optional
If this option is specified, the image will be downsampled by a factor downsample when reading in the data.
- northbool, optional
Whether to rotate the image so that north is up. By default, this is assumed to be ‘north’ in the ICRS frame, but you can also pass any astropy
BaseCoordinateFrame
to indicate to use the north of that frame.- conventionstr, optional
This is used in cases where a FITS header can be interpreted in multiple ways. For example, for files with a -CAR projection and CRVAL2=0, this can be set to ‘wells’ or ‘calabretta’ to choose the appropriate convention.
- dimensionstuple or list, optional
The index of the axes to use if the data has more than three dimensions.
- slicestuple or list, optional
If a FITS file with more than two dimensions is specified, then these are the slices to extract. If all extra dimensions only have size 1, then this is not required.
- auto_refreshbool, optional
Whether to refresh the figure automatically every time a plotting method is called. This can also be set using the set_auto_refresh method. This defaults to
True
if and only if APLpy is being used from IPython and the Matplotlib backend is interactive.- kwargs
Any additional arguments are passed on to matplotlib’s Figure() class. For example, to set the figure size, use the figsize=(xsize, ysize) argument (where xsize and ysize are in inches). For more information on these additional arguments, see the Optional keyword arguments section in the documentation for
Figure
.
Methods Summary
add_beam
(*args, **kwargs)Add a beam to the current figure.
add_colorbar
(*args, **kwargs)Add a colorbar to the current figure.
add_grid
()Add a coordinate to the current figure.
add_label
(x, y, text[, relative, color, ...])Add a text label.
add_scalebar
(length, *args, **kwargs)Add a scalebar to the current figure.
close
()Close the figure and free up the memory.
get_layer
(layer[, raise_exception])Return a layer object.
hide_grayscale
(*args, **kwargs)hide_layer
(layer[, raise_exception])Hide a layer.
Print a list of layers to standard output.
pixel2world
(xp, yp[, wcs])Convert pixel to world coordinates.
recenter
(x, y[, radius, width, height])Center the image on a given position and with a given radius.
refresh
([force])Refresh the display.
remove_beam
([beam_index])Removes the beam from the current figure.
Removes the colorbar from the current figure.
Removes the grid from the current figure.
remove_layer
(layer[, raise_exception])Remove a layer.
Removes the scalebar from the current figure.
save
(filename[, dpi, transparent, ...])Save the current figure to a file.
savefig
(filename[, dpi, transparent, ...])Save the current figure to a file.
set_auto_refresh
(refresh)Set whether the display should refresh after each method call.
set_nan_color
(color)Set the color for NaN pixels.
set_system_latex
(usetex)Set whether to use a real LaTeX installation or the built-in matplotlib LaTeX.
set_theme
(theme)Set the axes, ticks, grid, and image colors to a certain style (experimental).
set_title
(title, **kwargs)Set the figure title
set_xaxis_coord_type
(coord_type)Set the type of x coordinate.
set_yaxis_coord_type
(coord_type)Set the type of y coordinate.
show_arrows
(x, y, dx, dy[, width, ...])Overlay arrows on the current plot.
show_circles
(xw, yw, radius[, layer, ...])Overlay circles on the current plot.
show_colorscale
([vmin, vmid, vmax, pmin, ...])Show a colorscale image of the FITS file.
show_contour
([data, hdu, layer, levels, ...])Overlay contours on the current plot.
show_ellipses
(xw, yw, width, height[, ...])Overlay ellipses on the current plot.
show_grayscale
([vmin, vmid, vmax, pmin, ...])Show a grayscale image of the FITS file.
show_layer
(layer[, raise_exception])Show a layer.
show_lines
(line_list[, layer, zorder])Overlay lines on the current plot.
show_markers
(xw, yw[, layer, coords_frame])Overlay markers on the current plot.
show_polygons
(polygon_list[, layer, zorder])Overlay polygons on the current plot.
show_rectangles
(xw, yw, width, height[, ...])Overlay rectangles on the current plot.
show_regions
(region_file[, layer])Overplot regions as specified in the region file.
show_rgb
([filename, interpolation, ...])Show a 3-color image instead of the FITS file data.
show_vectors
(pdata, adata[, phdu, ahdu, ...])Overlay vectors on the current plot.
world2pixel
(xw, yw[, wcs])Convert world to pixel coordinates.
Methods Documentation
- add_beam(*args, **kwargs)[source]¶
Add a beam to the current figure.
Once this method has been run, a beam attribute becomes available, and can be used to control the aspect of the beam:
>>> f = aplpy.FITSFigure(...) >>> ... >>> f.add_beam() >>> f.beam.set_color('white') >>> f.beam.set_hatch('+') >>> ...
If more than one beam is added, the beam object becomes a list. In this case, to control the aspect of one of the beams, you will need to specify the beam index:
>>> ... >>> f.beam[2].set_hatch('/') >>> ...
- add_colorbar(*args, **kwargs)[source]¶
Add a colorbar to the current figure.
Once this method has been run, a colorbar attribute becomes available, and can be used to control the aspect of the colorbar:
>>> f = aplpy.FITSFigure(...) >>> ... >>> f.add_colorbar() >>> f.colorbar.set_width(0.3) >>> f.colorbar.set_location('top') >>> ...
- add_grid()[source]¶
Add a coordinate to the current figure.
Once this method has been run, a grid attribute becomes available, and can be used to control the aspect of the grid:
>>> f = aplpy.FITSFigure(...) >>> ... >>> f.add_grid() >>> f.grid.set_color('white') >>> f.grid.set_alpha(0.5) >>> ...
- add_label(x, y, text, relative=False, color='black', family=None, style=None, variant=None, stretch=None, weight=None, size=None, fontproperties=None, horizontalalignment='center', verticalalignment='center', layer=None, **kwargs)[source]¶
Add a text label.
- Parameters
- x, yfloat
Coordinates of the text label
- textstr
The label
- relativestr, optional
Whether the coordinates are to be interpreted as world coordinates (e.g. RA/Dec or longitude/latitude), or coordinates relative to the axes (where 0.0 is left or bottom and 1.0 is right or top).
- familystr, optional
The family of the font to use. This can either be a generic font family name, either ‘serif’, ‘sans-serif’, ‘cursive’, ‘fantasy’, or ‘monospace’, or a list of font names in decreasing order of priority.
- stylestr, optional
The font style. This can be ‘normal’, ‘italic’ or ‘oblique’.
- variantstr, optional
The font variant. This can be ‘normal’ or ‘small-caps’
- stretchstr or int or float, optional
The stretching (spacing between letters) for the font. This can either be a numeric value in the range 0-1000 or one of ‘ultra-condensed’, ‘extra-condensed’, ‘condensed’, ‘semi-condensed’, ‘normal’, ‘semi-expanded’, ‘expanded’, ‘extra-expanded’ or ‘ultra-expanded’.
- weightstr or int or float, optional
The weight (or boldness) of the font. This can either be a numeric value in the range 0-1000 or one of ‘ultralight’, ‘light’, ‘normal’, ‘regular’, ‘book’, ‘medium’, ‘roman’, ‘semibold’, ‘demibold’, ‘demi’, ‘bold’, ‘heavy’, ‘extra bold’, ‘black’.
- sizestr or int or float, optional
The size of the font. This can either be a numeric value (e.g. 12), giving the size in points, or one of ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, or ‘xx-large’.
- add_scalebar(length, *args, **kwargs)[source]¶
Add a scalebar to the current figure.
Once this method has been run, a scalebar attribute becomes available, and can be used to control the aspect of the scalebar:
>>> f = aplpy.FITSFigure(...) >>> ... >>> f.add_scalebar(0.01) # length has to be specified >>> f.scalebar.set_label('100 AU') >>> ...
- Parameters
- lengthfloat, or quantity
The length of the scalebar in degrees, an angular quantity, or angular unit
- labelstr, optional
Label to place below the scalebar
- cornerint, optional
Where to place the scalebar. Acceptable values are:, ‘left’, ‘right’, ‘top’, ‘bottom’, ‘top left’, ‘top right’, ‘bottom left’ (default), ‘bottom right’
- framestr, optional
Whether to display a frame behind the scalebar (default is False)
- kwargs
Additional arguments are passed to the matplotlib Rectangle and Text classes. See the matplotlib documentation for more details. In cases where the same argument exists for the two objects, the argument is passed to both the Text and Rectangle instance.
- get_layer(layer, raise_exception=True)¶
Return a layer object.
- Parameters
- layerstr
The name of the layer to return
- hide_layer(layer, raise_exception=True)¶
Hide a layer.
This differs from remove_layer in that if a layer is hidden it can be shown again using show_layer.
- Parameters
- layerstr
The name of the layer to hide
- list_layers()¶
Print a list of layers to standard output.
- pixel2world(xp, yp, wcs=None)[source]¶
Convert pixel to world coordinates.
- Parameters
- xpfloat or iterable
x pixel coordinate
- ypfloat or iterable
y pixel coordinate
- Returns
- xwfloat or iterable
x world coordinate
- ywfloat or iterable
y world coordinate
- recenter(x, y, radius=None, width=None, height=None)[source]¶
Center the image on a given position and with a given radius.
Either the radius or width/height arguments should be specified. The units of the radius or width/height should be the same as the world coordinates in the WCS. For images of the sky, this is often (but not always) degrees.
- Parameters
- x, yfloat
Coordinates to center on
- radiusfloat, optional
Radius of the region to view in degrees. This produces a square plot.
- widthfloat, optional
Width of the region to view. This should be given in conjunction with the height argument.
- heightfloat, optional
Height of the region to view. This should be given in conjunction with the width argument.
- refresh(force=True)[source]¶
Refresh the display.
- Parameters
- forcestr, optional
If set to False, refresh() will only have an effect if auto refresh is on. If set to True, the display will be refreshed whatever the auto refresh setting is set to. The default is True.
- remove_beam(beam_index=None)[source]¶
Removes the beam from the current figure.
If more than one beam is present, the index of the beam should be specified using beam_index=
- remove_layer(layer, raise_exception=True)¶
Remove a layer.
- Parameters
- layerstr
The name of the layer to remove
- save(filename, dpi=None, transparent=False, adjust_bbox=True, max_dpi=300, format=None)[source]¶
Save the current figure to a file.
- Parameters
- filenamestr or fileobj
The name of the file to save the plot to. This can be for example a PS, EPS, PDF, PNG, JPEG, or SVG file. Note that it is also possible to pass file-like object.
- dpifloat, optional
The output resolution, in dots per inch. If the output file is a vector graphics format (such as PS, EPS, PDF or SVG) only the image itself will be rasterized. If the output is a PS or EPS file and no dpi is specified, the dpi is automatically calculated to match the resolution of the image. If this value is larger than max_dpi, then dpi is set to max_dpi.
- transparentstr, optional
Whether to preserve transparency
- adjust_bboxstr, optional
Auto-adjust the bounding box for the output
- max_dpifloat, optional
The maximum resolution to output images at. If no maximum is wanted, enter None or 0.
- formatstr, optional
By default, APLpy tries to guess the file format based on the file extension, but the format can also be specified explicitly. Should be one of ‘eps’, ‘ps’, ‘pdf’, ‘svg’, ‘png’.
- savefig(filename, dpi=None, transparent=False, adjust_bbox=True, max_dpi=300, format=None)¶
Save the current figure to a file.
- Parameters
- filenamestr or fileobj
The name of the file to save the plot to. This can be for example a PS, EPS, PDF, PNG, JPEG, or SVG file. Note that it is also possible to pass file-like object.
- dpifloat, optional
The output resolution, in dots per inch. If the output file is a vector graphics format (such as PS, EPS, PDF or SVG) only the image itself will be rasterized. If the output is a PS or EPS file and no dpi is specified, the dpi is automatically calculated to match the resolution of the image. If this value is larger than max_dpi, then dpi is set to max_dpi.
- transparentstr, optional
Whether to preserve transparency
- adjust_bboxstr, optional
Auto-adjust the bounding box for the output
- max_dpifloat, optional
The maximum resolution to output images at. If no maximum is wanted, enter None or 0.
- formatstr, optional
By default, APLpy tries to guess the file format based on the file extension, but the format can also be specified explicitly. Should be one of ‘eps’, ‘ps’, ‘pdf’, ‘svg’, ‘png’.
- set_auto_refresh(refresh)[source]¶
Set whether the display should refresh after each method call.
- Parameters
- refreshbool
Whether to refresh the display every time a FITSFigure method is called. This defaults to
True
if and only if APLpy is being used from IPython and the Matplotlib backend is interactive.
- set_nan_color(color)[source]¶
Set the color for NaN pixels.
- Parameters
- colorstr
This can be any valid matplotlib color
- set_system_latex(usetex)[source]¶
Set whether to use a real LaTeX installation or the built-in matplotlib LaTeX.
- Parameters
- usetexstr
Whether to use a real LaTex installation (True) or the built-in matplotlib LaTeX (False). Note that if the former is chosen, an installation of LaTex is required.
- set_theme(theme)[source]¶
Set the axes, ticks, grid, and image colors to a certain style (experimental).
- Parameters
- themestr
The theme to use. At the moment, this can be ‘pretty’ (for viewing on-screen) and ‘publication’ (which makes the ticks and grid black, and displays the image in inverted grayscale)
- set_xaxis_coord_type(coord_type)[source]¶
Set the type of x coordinate.
Options are:
scalar
: treat the values are normal decimal scalar valueslongitude
: treat the values as a longitude in the 0 to 360 rangelatitude
: treat the values as a latitude in the -90 to 90 range
- set_yaxis_coord_type(coord_type)[source]¶
Set the type of y coordinate.
Options are:
scalar
: treat the values are normal decimal scalar valueslongitude
: treat the values as a longitude in the 0 to 360 rangelatitude
: treat the values as a latitude in the -90 to 90 range
- show_arrows(x, y, dx, dy, width='auto', head_width='auto', head_length='auto', length_includes_head=True, layer=False, zorder=None, **kwargs)[source]¶
Overlay arrows on the current plot.
- Parameters
- x, y, dx, dyfloat or list or
ndarray
Origin and displacement of the arrows in world coordinates. These can either be scalars to plot a single arrow, or lists or arrays to plot multiple arrows.
- widthfloat, optional
The width of the arrow body, in pixels (default: 2% of the arrow length)
- head_widthfloat, optional
The width of the arrow head, in pixels (default: 5% of the arrow length)
- head_lengthfloat, optional
The length of the arrow head, in pixels (default: 5% of the arrow length)
- length_includes_headbool, optional
Whether the head includes the length
- layerstr, optional
The name of the arrow(s) layer. This is useful for giving custom names to layers (instead of line_set_n) and for replacing existing layers.
- kwargs
Additional keyword arguments (such as facecolor, edgecolor, alpha, or linewidth) are passed to Matplotlib
PatchCollection
class, and can be used to control the appearance of the arrows.
- x, y, dx, dyfloat or list or
- show_circles(xw, yw, radius, layer=False, coords_frame='world', zorder=None, **kwargs)[source]¶
Overlay circles on the current plot.
- Parameters
- xwlist or
ndarray
The x positions of the centers of the circles (in world coordinates)
- ywlist or
ndarray
The y positions of the centers of the circles (in world coordinates)
- radiusint or float or list or
ndarray
The radii of the circles (in world coordinates)
- layerstr, optional
The name of the circle layer. This is useful for giving custom names to layers (instead of circle_set_n) and for replacing existing layers.
- coords_frame‘pixel’ or ‘world’
The reference frame in which the coordinates are defined. This is used to interpret the values of
xw
andyw
.- kwargs
Additional keyword arguments (such as facecolor, edgecolor, alpha, or linewidth) are passed to Matplotlib
PatchCollection
class, and can be used to control the appearance of the circles.
- xwlist or
- show_colorscale(vmin=None, vmid=None, vmax=None, pmin=0.25, pmax=99.75, stretch='linear', exponent=2, cmap='default', smooth=None, kernel='gauss', aspect='equal', interpolation='nearest')[source]¶
Show a colorscale image of the FITS file.
- Parameters
- vminNone or float, optional
Minimum pixel value to use for the colorscale. If set to None, the minimum pixel value is determined using pmin (default).
- vmaxNone or float, optional
Maximum pixel value to use for the colorscale. If set to None, the maximum pixel value is determined using pmax (default).
- pminfloat, optional
Percentile value used to determine the minimum pixel value to use for the colorscale if vmin is set to None. The default value is 0.25%.
- pmaxfloat, optional
Percentile value used to determine the maximum pixel value to use for the colorscale if vmax is set to None. The default value is 99.75%.
- stretch{ ‘linear’, ‘log’, ‘sqrt’, ‘arcsinh’, ‘power’ }, optional
The stretch function to use
- vmidNone or float, optional
Baseline value used for the log and arcsinh stretches. If not set, this defaults to zero for log stretches and to vmin - (vmax - vmin) / 30. for arcsinh stretches
- exponentfloat, optional
If stretch is set to ‘power’, this is the exponent to use
- cmapstr, optional
The name of the colormap to use
- smoothint or tuple, optional
Default smoothing scale is 3 pixels across. User can define whether they want an NxN kernel (integer), or NxM kernel (tuple). This argument corresponds to the ‘gauss’ and ‘box’ smoothing kernels.
- kernel{ ‘gauss’, ‘box’, numpy.array }, optional
Default kernel used for smoothing is ‘gauss’. The user can specify if they would prefer ‘gauss’, ‘box’, or a custom kernel. All kernels are normalized to ensure flux retention.
- aspect{ ‘auto’, ‘equal’ }, optional
Whether to change the aspect ratio of the image to match that of the axes (‘auto’) or to change the aspect ratio of the axes to match that of the data (‘equal’; default)
- interpolationstr, optional
The type of interpolation to use for the image. The default is ‘nearest’. Other options include ‘none’ (no interpolation, meaning that if exported to a postscript file, the colorscale will be output at native resolution irrespective of the dpi setting), ‘bilinear’, ‘bicubic’, and many more (see the matplotlib documentation for imshow).
- show_contour(data=None, hdu=0, layer=None, levels=5, filled=False, cmap=None, colors=None, returnlevels=False, convention=None, dimensions=[0, 1], slices=[], smooth=None, kernel='gauss', overlap=False, **kwargs)[source]¶
Overlay contours on the current plot.
- Parameters
- datasee below
The FITS file to plot contours for. The following data types can be passed:
string astropy.io.fits.PrimaryHDU astropy.io.fits.ImageHDU astropy.wcs.WCS np.ndarray
- hduint, optional
By default, the image in the primary HDU is read in. If a different HDU is required, use this argument.
- layerstr, optional
The name of the contour layer. This is useful for giving custom names to layers (instead of contour_set_n) and for replacing existing layers.
- levelsint or list, optional
This can either be the number of contour levels to compute (if an integer is provided) or the actual list of contours to show (if a list of floats is provided)
- filledstr, optional
Whether to show filled or line contours
- cmapstr, optional
The colormap to use for the contours
- colorsstr or tuple, optional
If a single string is provided, all contour levels will be shown in this color. If a tuple of strings is provided, each contour will be colored according to the corresponding tuple element.
- returnlevelsstr, optional
Whether to return the list of contours to the caller.
- conventionstr, optional
This is used in cases where a FITS header can be interpreted in multiple ways. For example, for files with a -CAR projection and CRVAL2=0, this can be set to ‘wells’ or ‘calabretta’ to choose the appropriate convention.
- dimensionstuple or list, optional
The index of the axes to use if the data has more than three dimensions.
- slicestuple or list, optional
If a FITS file with more than two dimensions is specified, then these are the slices to extract. If all extra dimensions only have size 1, then this is not required.
- smoothint or tuple, optional
Default smoothing scale is 3 pixels across. User can define whether they want an NxN kernel (integer), or NxM kernel (tuple). This argument corresponds to the ‘gauss’ and ‘box’ smoothing kernels.
- kernel{ ‘gauss’ , ‘box’ , numpy.array }, optional
Default kernel used for smoothing is ‘gauss’. The user can specify if they would prefer ‘gauss’, ‘box’, or a custom kernel. All kernels are normalized to ensure flux retention.
- overlap str, optional
Whether to include only contours that overlap with the image area. This significantly speeds up the drawing of contours and reduces file size when using a file for the contours covering a much larger area than the image.
- kwargs
Additional keyword arguments (such as alpha, linewidths, or linestyles) will be passed on directly to Matplotlib’s
contour()
orcontourf()
methods. For more information on these additional arguments, see the Optional keyword arguments sections in the documentation for those methods.
- show_ellipses(xw, yw, width, height, angle=0, layer=False, zorder=None, coords_frame='world', **kwargs)[source]¶
Overlay ellipses on the current plot.
- Parameters
- xwlist or
ndarray
The x positions of the centers of the ellipses (in world coordinates)
- ywlist or
ndarray
The y positions of the centers of the ellipses (in world coordinates)
- widthint or float or list or
ndarray
The width of the ellipse (in world coordinates)
- heightint or float or list or
ndarray
The height of the ellipse (in world coordinates)
- angleint or float or list or
ndarray
, optional rotation in degrees (anti-clockwise). Default angle is 0.0.
- layerstr, optional
The name of the ellipse layer. This is useful for giving custom names to layers (instead of ellipse_set_n) and for replacing existing layers.
- coords_frame‘pixel’ or ‘world’
The reference frame in which the coordinates are defined. This is used to interpret the values of
xw
,yw
,width
, andheight
.- kwargs
Additional keyword arguments (such as facecolor, edgecolor, alpha, or linewidth) are passed to Matplotlib
PatchCollection
class, and can be used to control the appearance of the ellipses.
- xwlist or
- show_grayscale(vmin=None, vmid=None, vmax=None, pmin=0.25, pmax=99.75, stretch='linear', exponent=2, invert='default', smooth=None, kernel='gauss', aspect='equal', interpolation='nearest')[source]¶
Show a grayscale image of the FITS file.
- Parameters
- vminNone or float, optional
Minimum pixel value to use for the grayscale. If set to None, the minimum pixel value is determined using pmin (default).
- vmaxNone or float, optional
Maximum pixel value to use for the grayscale. If set to None, the maximum pixel value is determined using pmax (default).
- pminfloat, optional
Percentile value used to determine the minimum pixel value to use for the grayscale if vmin is set to None. The default value is 0.25%.
- pmaxfloat, optional
Percentile value used to determine the maximum pixel value to use for the grayscale if vmax is set to None. The default value is 99.75%.
- stretch{ ‘linear’, ‘log’, ‘sqrt’, ‘arcsinh’, ‘power’ }, optional
The stretch function to use
- vmidNone or float, optional
Baseline value used for the log and arcsinh stretches. If set to None, this is set to zero for log stretches and to vmin - (vmax - vmin) / 30. for arcsinh stretches
- exponentfloat, optional
If stretch is set to ‘power’, this is the exponent to use
- invertstr, optional
Whether to invert the grayscale or not. The default is False, unless set_theme is used, in which case the default depends on the theme.
- smoothint or tuple, optional
Default smoothing scale is 3 pixels across. User can define whether they want an NxN kernel (integer), or NxM kernel (tuple). This argument corresponds to the ‘gauss’ and ‘box’ smoothing kernels.
- kernel{ ‘gauss’, ‘box’, numpy.array }, optional
Default kernel used for smoothing is ‘gauss’. The user can specify if they would prefer ‘gauss’, ‘box’, or a custom kernel. All kernels are normalized to ensure flux retention.
- aspect{ ‘auto’, ‘equal’ }, optional
Whether to change the aspect ratio of the image to match that of the axes (‘auto’) or to change the aspect ratio of the axes to match that of the data (‘equal’; default)
- interpolationstr, optional
The type of interpolation to use for the image. The default is ‘nearest’. Other options include ‘none’ (no interpolation, meaning that if exported to a postscript file, the grayscale will be output at native resolution irrespective of the dpi setting), ‘bilinear’, ‘bicubic’, and many more (see the matplotlib documentation for imshow).
- show_layer(layer, raise_exception=True)¶
Show a layer.
This shows a layer previously hidden with hide_layer
- Parameters
- layerstr
The name of the layer to show
- show_lines(line_list, layer=False, zorder=None, **kwargs)[source]¶
Overlay lines on the current plot.
- Parameters
- line_listlist
A list of one or more 2xN numpy arrays which contain the [x, y] positions of the vertices in world coordinates.
- layerstr, optional
The name of the line(s) layer. This is useful for giving custom names to layers (instead of line_set_n) and for replacing existing layers.
- kwargs
Additional keyword arguments (such as color, offsets, linestyle, or linewidth) are passed to Matplotlib
LineCollection
class, and can be used to control the appearance of the lines.
- show_markers(xw, yw, layer=False, coords_frame='world', **kwargs)[source]¶
Overlay markers on the current plot.
- Parameters
- xwlist or
ndarray
The x positions of the markers (in world coordinates)
- ywlist or
ndarray
The y positions of the markers (in world coordinates)
- layerstr, optional
The name of the scatter layer. This is useful for giving custom names to layers (instead of marker_set_n) and for replacing existing layers.
- coords_frame‘pixel’ or ‘world’
The reference frame in which the coordinates are defined. This is used to interpret the values of
xw
andyw
.- kwargs
Additional keyword arguments (such as marker, facecolor, edgecolor, alpha, or linewidth) will be passed on directly to Matplotlib’s
scatter()
method (in particular, have a look at the Optional keyword arguments in the documentation for that method).
- xwlist or
- show_polygons(polygon_list, layer=False, zorder=None, **kwargs)[source]¶
Overlay polygons on the current plot.
- Parameters
- polygon_listlist or tuple
A list of one or more 2xN or Nx2 Numpy arrays which contain the [x, y] positions of the vertices in world coordinates. Note that N should be greater than 2.
- layerstr, optional
The name of the circle layer. This is useful for giving custom names to layers (instead of circle_set_n) and for replacing existing layers.
- kwargs
Additional keyword arguments (such as facecolor, edgecolor, alpha, or linewidth) are passed to Matplotlib
PatchCollection
class, and can be used to control the appearance of the polygons.
- show_rectangles(xw, yw, width, height, angle=0, layer=False, zorder=None, coords_frame='world', **kwargs)[source]¶
Overlay rectangles on the current plot.
- Parameters
- xwlist or
ndarray
The x positions of the centers of the rectangles (in world coordinates)
- ywlist or
ndarray
The y positions of the centers of the rectangles (in world coordinates)
- widthint or float or list or
ndarray
The width of the rectangle (in world coordinates)
- heightint or float or list or
ndarray
The height of the rectangle (in world coordinates)
- angleint or float or list or
ndarray
, optional rotation in degrees (anti-clockwise). Default angle is 0.0.
- layerstr, optional
The name of the rectangle layer. This is useful for giving custom names to layers (instead of rectangle_set_n) and for replacing existing layers.
- coords_frame‘pixel’ or ‘world’
The reference frame in which the coordinates are defined. This is used to interpret the values of
xw
,yw
,width
, andheight
.- kwargs
Additional keyword arguments (such as facecolor, edgecolor, alpha, or linewidth) are passed to Matplotlib
PatchCollection
class, and can be used to control the appearance of the rectangles.
- xwlist or
- show_regions(region_file, layer=False, **kwargs)¶
Overplot regions as specified in the region file.
- Parameters
- region_file: string or pyregion.ShapeList
Path to a ds9 regions file or a ShapeList already read in by pyregion.
- layer: str, optional
The name of the layer
- kwargs
Additional keyword arguments, e.g. zorder, will be passed to the ds9 call and onto the patchcollections.
- show_rgb(filename=None, interpolation='nearest', vertical_flip=False, horizontal_flip=False, flip=False)[source]¶
Show a 3-color image instead of the FITS file data.
- Parameters
- filename, optional
The 3-color image should have exactly the same dimensions as the FITS file, and will be shown with exactly the same projection. If FITSFigure was initialized with an AVM-tagged RGB image, the filename is not needed here.
- vertical_flipstr, optional
Whether to vertically flip the RGB image
- horizontal_flipstr, optional
Whether to horizontally flip the RGB image
- show_vectors(pdata, adata, phdu=0, ahdu=0, step=1, scale=1, rotate=0, cutoff=0, units='degrees', layer=None, convention=None, dimensions=[0, 1], slices=[], **kwargs)[source]¶
Overlay vectors on the current plot.
- Parameters
- pdatasee below
The FITS file specifying the magnitude of vectors. The following data types can be passed:
string astropy.io.fits.PrimaryHDU astropy.io.fits.ImageHDU astropy.wcs.WCS np.ndarray
- adatasee below
The FITS file specifying the angle of vectors. The following data types can be passed:
string astropy.io.fits.PrimaryHDU astropy.io.fits.ImageHDU astropy.wcs.WCS np.ndarray
- phduint, optional
By default, the image in the primary HDU is read in. If a different HDU is required for pdata, use this argument.
- ahduint, optional
By default, the image in the primary HDU is read in. If a different HDU is required for adata, use this argument.
- stepint, optional
Derive a vector only from every ‘step’ pixels. You will normally want this to be >1 to get sensible vector spacing.
- scaleint, optional
The length, in pixels, of a vector with magnitude 1 in the image specified by pdata. If pdata specifies fractional polarization, make this comparable to step.
- rotatefloat, optional
An angle to rotate by, in units the same as those of the angle map.
- cutofffloat, optional
The value of magnitude below which no vectors should be plotted. The default value, zero, excludes negative-length and NaN-masked data.
- unitsstr, optional
Units to assume for the angle map. Valid values are ‘degrees’ (the default) or ‘radians’ (or anything else), which will not apply a scaling factor of pi/180 to the angle data.
- layerstr, optional
The name of the vector layer. This is useful for giving custom names to layers (instead of vector_set_n) and for replacing existing layers.
- conventionstr, optional
This is used in cases where a FITS header can be interpreted in multiple ways. For example, for files with a -CAR projection and CRVAL2=0, this can be set to ‘wells’ or ‘calabretta’ to choose the appropriate convention.
- dimensionstuple or list, optional
The index of the axes to use if the data has more than three dimensions.
- slicestuple or list, optional
If a FITS file with more than two dimensions is specified, then these are the slices to extract. If all extra dimensions only have size 1, then this is not required.
- kwargs
Additional keyword arguments (such as alpha, linewidths, or color) which are passed to Matplotlib’s
LineCollection
class, and can be used to control the appearance of the lines. For more information on these additional arguments, see the Optional keyword arguments sections in the documentation for those methods.