CoordinateHelper¶
-
class
astropy.visualization.wcsaxes.
CoordinateHelper
(parent_axes=None, parent_map=None, transform=None, coord_index=None, coord_type='scalar', coord_unit=None, coord_wrap=None, frame=None, format_unit=None, default_label=None)[source]¶ Bases:
object
Helper class to control one of the coordinates in the
WCSAxes
.- Parameters
- parent_axes
WCSAxes
The axes the coordinate helper belongs to.
- parent_map
CoordinatesMap
The
CoordinatesMap
object this coordinate belongs to.- transform
Transform
The transform corresponding to this coordinate system.
- coord_indexint
The index of this coordinate in the
CoordinatesMap
.- coord_type{‘longitude’, ‘latitude’, ‘scalar’}
The type of this coordinate, which is used to determine the wrapping and boundary behavior of coordinates. Longitudes wrap at
coord_wrap
, latitudes have to be in the range -90 to 90, and scalars are unbounded and do not wrap.- coord_unit
Unit
The unit that this coordinate is in given the output of transform.
- format_unit
Unit
, optional The unit to use to display the coordinates.
- coord_wrapfloat
The angle at which the longitude wraps (defaults to 360)
- frame
BaseFrame
The frame of the
WCSAxes
.
- parent_axes
Attributes Summary
Methods Summary
display_minor_ticks
(self, display_minor_ticks)Display minor ticks for this coordinate.
format_coord
(self, value[, format])Given the value of a coordinate, will format it according to the format of the formatter_locator.
get_auto_axislabel
(self)Render default axis labels if no explicit label is provided.
get_axislabel
(self)Get the text for the axis label
get_axislabel_visibility_rule
(self, rule)Get the rule used to determine when the axis label is drawn.
get_format_unit
(self)Get the unit for the major tick labels.
get_minor_frequency
(self)grid
(self[, draw_grid, grid_type])Plot grid lines for this coordinate.
set_auto_axislabel
(self, auto_label)Render default axis labels if no explicit label is provided.
set_axislabel
(self, text[, minpad])Set the text and optionally visual properties for the axis label.
set_axislabel_position
(self, position)Set where axis labels should appear
set_axislabel_visibility_rule
(self, rule)Set the rule used to determine when the axis label is drawn.
set_coord_type
(self, coord_type[, coord_wrap])Set the coordinate type for the axis.
set_format_unit
(self, unit[, decimal, …])Set the unit for the major tick labels.
set_major_formatter
(self, formatter)Set the formatter to use for the major tick labels.
set_minor_frequency
(self, frequency)Set the frequency of minor ticks per major ticks.
set_separator
(self, separator)Set the separator to use for the angle major tick labels.
set_ticklabel
(self[, color, size, pad, …])Set the visual properties for the tick labels.
set_ticklabel_position
(self, position)Set where tick labels should appear
set_ticklabel_visible
(self, visible)Set whether the tick labels are visible or not.
set_ticks
(self[, values, spacing, number, …])Set the location and properties of the ticks.
set_ticks_position
(self, position)Set where ticks should appear
set_ticks_visible
(self, visible)Set whether ticks are visible or not.
tick_params
(self[, which])Method to set the tick and tick label parameters in the same way as the
tick_params()
method in Matplotlib.Attributes Documentation
-
formatter
¶
-
locator
¶
Methods Documentation
-
display_minor_ticks
(self, display_minor_ticks)[source]¶ Display minor ticks for this coordinate.
- Parameters
- display_minor_ticksbool
Whether or not to display minor ticks.
-
format_coord
(self, value, format='auto')[source]¶ Given the value of a coordinate, will format it according to the format of the formatter_locator.
- Parameters
- valuefloat
The value to format
- format{‘auto’, ‘ascii’, ‘latex’}, optional
The format to use - by default the formatting will be adjusted depending on whether Matplotlib is using LaTeX or MathTex. To get plain ASCII strings, use format=’ascii’.
-
get_axislabel_visibility_rule
(self, rule)[source]¶ Get the rule used to determine when the axis label is drawn.
-
grid
(self, draw_grid=True, grid_type=None, **kwargs)[source]¶ Plot grid lines for this coordinate.
Standard matplotlib appearance options (color, alpha, etc.) can be passed as keyword arguments.
- Parameters
- draw_gridbool
Whether to show the gridlines
- grid_type{‘lines’, ‘contours’}
Whether to plot the contours by determining the grid lines in world coordinates and then plotting them in world coordinates (
'lines'
) or by determining the world coordinates at many positions in the image and then drawing contours ('contours'
). The first is recommended for 2-d images, while for 3-d (or higher dimensional) cubes, the'contours'
option is recommended. By default, ‘lines’ is used if the transform has an inverse, otherwise ‘contours’ is used.
-
set_auto_axislabel
(self, auto_label)[source]¶ Render default axis labels if no explicit label is provided.
-
set_axislabel
(self, text, minpad=1, **kwargs)[source]¶ Set the text and optionally visual properties for the axis label.
- Parameters
- textstr
The axis label text.
- minpadfloat, optional
The padding for the label in terms of axis label font size.
- kwargs
Keywords are passed to
matplotlib.text.Text
. These can include keywords to set thecolor
,size
,weight
, and other text properties.
-
set_axislabel_position
(self, position)[source]¶ Set where axis labels should appear
- Parameters
- positionstr
The axes on which the axis label for this coordinate should appear. Should be a string containing zero or more of
'b'
,'t'
,'l'
,'r'
. For example,'lb'
will lead the axis label to be shown on the left and bottom axis.
-
set_axislabel_visibility_rule
(self, rule)[source]¶ Set the rule used to determine when the axis label is drawn.
- Parameters
- rulestr
If the rule is ‘always’ axis labels will always be drawn on the axis. If the rule is ‘ticks’ the label will only be drawn if ticks were drawn on that axis. If the rule is ‘labels’ the axis label will only be drawn if tick labels were drawn on that axis.
-
set_coord_type
(self, coord_type, coord_wrap=None)[source]¶ Set the coordinate type for the axis.
- Parameters
- coord_typestr
One of ‘longitude’, ‘latitude’ or ‘scalar’
- coord_wrapfloat, optional
The value to wrap at for angular coordinates
-
set_format_unit
(self, unit, decimal=None, show_decimal_unit=True)[source]¶ Set the unit for the major tick labels.
- Parameters
- unitclass:
Unit
The unit to which the tick labels should be converted to.
- decimalbool, optional
Whether to use decimal formatting. By default this is
False
for degrees or hours (which therefore use sexagesimal formatting) andTrue
for all other units.- show_decimal_unitbool, optional
Whether to include units when in decimal mode.
- unitclass:
-
set_major_formatter
(self, formatter)[source]¶ Set the formatter to use for the major tick labels.
- Parameters
- formatterstr or Formatter
The format or formatter to use.
-
set_minor_frequency
(self, frequency)[source]¶ Set the frequency of minor ticks per major ticks.
- Parameters
- frequencyint
The number of minor ticks per major ticks.
-
set_separator
(self, separator)[source]¶ Set the separator to use for the angle major tick labels.
- Parameters
- separatorstr or tuple or None
The separator between numbers in sexagesimal representation. Can be either a string or a tuple (or
None
for default).
-
set_ticklabel
(self, color=None, size=None, pad=None, exclude_overlapping=None, **kwargs)[source]¶ Set the visual properties for the tick labels.
- Parameters
- sizefloat, optional
The size of the ticks labels in points
- colorstr or tuple, optional
A valid Matplotlib color for the tick labels
- padfloat, optional
Distance in points between tick and label.
- exclude_overlappingbool, optional
Whether to exclude tick labels that overlap over each other.
- kwargs
Other keyword arguments are passed to
matplotlib.text.Text
.
-
set_ticklabel_position
(self, position)[source]¶ Set where tick labels should appear
- Parameters
- positionstr
The axes on which the tick labels for this coordinate should appear. Should be a string containing zero or more of
'b'
,'t'
,'l'
,'r'
. For example,'lb'
will lead the tick labels to be shown on the left and bottom axis.
-
set_ticklabel_visible
(self, visible)[source]¶ Set whether the tick labels are visible or not.
- Parameters
- visiblebool
The visibility of ticks. Setting as
False
will hide this coordinate’s tick labels.
-
set_ticks
(self, values=None, spacing=None, number=None, size=None, width=None, color=None, alpha=None, direction=None, exclude_overlapping=None)[source]¶ Set the location and properties of the ticks.
At most one of the options from
values
,spacing
, ornumber
can be specified.- Parameters
- valuesiterable, optional
The coordinate values at which to show the ticks.
- spacingfloat, optional
The spacing between ticks.
- numberfloat, optional
The approximate number of ticks shown.
- sizefloat, optional
The length of the ticks in points
- colorstr or tuple, optional
A valid Matplotlib color for the ticks
- alphafloat, optional
The alpha value (transparency) for the ticks.
- direction{‘in’,’out’}, optional
Whether the ticks should point inwards or outwards.
-
set_ticks_position
(self, position)[source]¶ Set where ticks should appear
- Parameters
- positionstr
The axes on which the ticks for this coordinate should appear. Should be a string containing zero or more of
'b'
,'t'
,'l'
,'r'
. For example,'lb'
will lead the ticks to be shown on the left and bottom axis.
-
set_ticks_visible
(self, visible)[source]¶ Set whether ticks are visible or not.
- Parameters
- visiblebool
The visibility of ticks. Setting as
False
will hide ticks along this coordinate.
-
tick_params
(self, which='both', **kwargs)[source]¶ Method to set the tick and tick label parameters in the same way as the
tick_params()
method in Matplotlib.This is provided for convenience, but the recommended API is to use
set_ticks()
,set_ticklabel()
,set_ticks_position()
,set_ticklabel_position()
, andgrid()
.- Parameters
- which{‘both’, ‘major’, ‘minor’}, optional
Which ticks to apply the settings to. By default, setting are applied to both major and minor ticks. Note that if
'minor'
is specified, only the length of the ticks can be set currently.- direction{‘in’, ‘out’}, optional
Puts ticks inside the axes, or outside the axes.
- lengthfloat, optional
Tick length in points.
- widthfloat, optional
Tick width in points.
- colorcolor, optional
Tick color (accepts any valid Matplotlib color)
- padfloat, optional
Distance in points between tick and label.
- labelsizefloat or str, optional
Tick label font size in points or as a string (e.g., ‘large’).
- labelcolorcolor, optional
Tick label color (accepts any valid Matplotlib color)
- colorscolor, optional
- Changes the tick color and the label color to the same value
(accepts any valid Matplotlib color).
- bottom, top, left, rightbool, optional
Where to draw the ticks. Note that this will not work correctly if the frame is not rectangular.
- labelbottom, labeltop, labelleft, labelrightbool, optional
Where to draw the tick labels. Note that this will not work correctly if the frame is not rectangular.
- grid_colorcolor, optional
The color of the grid lines (accepts any valid Matplotlib color).
- grid_alphafloat, optional
Transparency of grid lines: 0 (transparent) to 1 (opaque).
- grid_linewidthfloat, optional
Width of grid lines in points.
- grid_linestylestr, optional
The style of the grid lines (accepts any valid Matplotlib line style).