Last modified: December 2014

URL: https://cxc.cfa.harvard.edu/chips/ahelp/set_axis.html
AHELP for CIAO 4.11 ChIPS v1

set_axis

Context: axes

Synopsis

Modifies the attributes of an existing axis.

Syntax

set_axis(attributes)
set_axis(id, attributes)

Individual axes may also be modified using the set_xaxis() and
set_yaxis() routines.

Description

The function arguments.

Argument Description
id A ChipsId structure identifying the item, or a string containing the name of the object.
attributes Configure object properties by giving an attribute string (a space-separated list of key=value pairs), list, dictionary, or a ChIPS object.

The set_axis command sets the specified attributes to the provided values. If an axis id is specified then this selects the axis to use and makes it current, if it isn't already, otherwise the command operates on the current x and y axes. An individual axis may also be modified with set_xaxis and set_yaxis commands.

Customizing the Axis

There are several attributes that control the characteristics of axes. The set_axis command may be used to modify the attribute values of an existing axis at any time during a ChIPS session. See "ahelp attributes" and "ahelp setget" for more general information.

If multiple attributes are being set simultaneously and one of them fails, the entire command will fail and the axis will not be modified.

Please see the "Axis Preferences and Attributes" section below the examples for a list of the axis attributes.

Axis labels

The x.label.angle, x.label.text, y.label.angle, and y.label.text fields allow you to both retrieve the label text by saying

xlbl = get_xaxis("ax1", "x.label.text")
ylbl = get_yaxis("ay1", "y.label.text")

or to change it with calls like

set_yaxis(['y.label.text', 'Flux (erg/cm^s/s)'])

Note that the "x." or "y." suffix must be used, even when using the get_xaxis/yaxis or set_xaxis/yaxis routines. The set_plot_xlabel(), set_plot_ylabel(), and get_axis_text() routines can also be used to change the label text.

Advanced Functions

The module of advanced ChIPS functions contains other commands for setting attribute values (refer to "ahelp chips" for information on loading the module):

set_axis_automax
set_axis_automin
set_axis_color
set_axis_depth
set_axis_label_angle
set_axis_label_color
set_axis_label_font
set_axis_label_fontstyle
set_axis_label_halign
set_axis_label_size
set_axis_label_valign
set_axis_label_visible
set_axis_major_color
set_axis_major_interval
set_axis_major_length
set_axis_major_mode
set_axis_major_num
set_axis_major_style
set_axis_major_thickness
set_axis_majorgrid_color
set_axis_majorgrid_style
set_axis_majorgrid_thickness
set_axis_majorgrid_visible
set_axis_minor_color
set_axis_minor_interval
set_axis_minor_length
set_axis_minor_mode
set_axis_minor_num
set_axis_minor_style
set_axis_minor_thickness
set_axis_minorgrid_color
set_axis_minorgrid_style
set_axis_minorgrid_thickness
set_axis_minorgrid_visible
set_axis_pad
set_axis_parallel_offset
set_axis_perpendicular_offset
set_axis_thickness
set_axis_tickformat
set_axis_ticklabel_angle
set_axis_ticklabel_color
set_axis_ticklabel_font
set_axis_ticklabel_fontstyle
set_axis_ticklabel_halign
set_axis_ticklabel_offset
set_axis_ticklabel_size
set_axis_ticklabel_style
set_axis_ticklabel_valign
set_axis_ticklabel_visible
set_axis_tickstyle

Examples

Example 1

chips> set_axis(["color", "blue", "thickness", 2, "tickformat",
"%0.0z"])

Using attribute/value pairs, set the x and y axis color to blue, the thickness to 2, and the tickformat style to use n * 10^x notation.

The "%0.0z" tickformat is ideal for logarithmically-scaled axes, since it suppresses the leading "1 x" from the label if all major tick marks are at an exact power of 10.

Example 2

chips> avals = {"color": "blue", "thickness": 2, "tickformat": "%0.0z"}
chips> set_axis(avals)

This is a repeat of the previous example but this time using a dictionary, rather than a list of attribute/value pairs, for defining the new values.

Example 3

chips> set_axis("ax1", ["tickformat", "ra"])
chips> set_axis("ay1", ["tickformat", "dec"])

Change the current X axis to label the axis using sexagesimal hour notation and the Y axis to sexagesimal degrees.

The following calls are equivalent - assuming "ax1" and "ay1" are the names of the current X and Y axes respectively:

chips> set_xaxis(["tickformat", "ra"])
chips> set_yaxis(["tickformat", "dec"])

Example 4

chips> set_axis("ay1", ["y.label.text", "Dec", "y.label.angle", 0])

This sets the Y-axis label to the string Dec and changes its angle so that it is written horizontally. The default for y axis labels is that their angle is 90, which means that they are written vertically, reading from bottom to top.

Example 5

chips> set_axis(["*.color", "blue"])

Change all the color attributes of both axes - such as the label and tick mark colors - to blue.

Example 6

chips> s = ChipsAxis()
chips> s.color = "steelblue"
chips> s.ticklabel.angle = 45
chips> s.ticklabel.halign = "right"
chips> s.majorgrid.visible = True
chips> set_axis("ax1", s)

Populate the "s" structure with the attribute values, then use it to set axis ax1 to have visible major grids, right-justified tick labels rotated at 45 degrees, and a steelblue baseline color.

Example 7

chips> s = ChipsAxis()
chips> s.all.color = "gray"
chips> s.all.font = "times"
chips> set_axis(s)

Set both current axes to use gray for all color elements and times for all font elements.


Axis Preferences and Attributes

The attributes associated with axes are given in the following table, where the "Set?" column refers to whether the attribute can be changed using the set_axis() command. To change the axis preference settings prepend "axis." to the attribute name.

Attribute Description Options Default Set?
automin Should the axis automatically reset its minimum when a curve, histogram, image, or contour is added? see the Booleans section of "ahelp chipsopt" true Yes
automax Should the axis automatically reset its maximum when a curve, histogram, image, or contour is added? see the Booleans section of "ahelp chipsopt" true Yes
color Color of the axis base line segment name or hex; see the Color section of "ahelp chipsopt" default Yes
coordsys coordinate system for the axis PIXEL, WINDOW_NORM, FRAME_NORM, PLOT_NORM, DATA see "ahelp coordsys" No
depth Integer value indicating axis depth see the Depth section of "ahelp chipsopt" default Yes
label.color Color of the axis label name or hex; see the Color section of "ahelp chipsopt" default Yes
label.font font for the axis label text helvetica|courier|times|greek; see the Font section of "ahelp chipsopt" helvetica Yes
label.fontstyle style of the axis label text normal|bold|italic|bolditalic; see the Font Style section of "ahelp chipsopt" normal Yes
label.halign Horizontal location of the string reference point of the axis label auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" center Yes
label.size Font size of the axis label 1 to 100 14 Yes
label.valign Vertical location of the string reference point of the axis label auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" center Yes
majorgrid.color Color of the axis major grids name or hex; see the Color section of "ahelp chipsopt" default Yes
majorgrid.style stipple pattern used to draw the axis major grids see the Line Style section of "ahelp chipsopt" shortdash Yes
majorgrid.thickness Thickness of the axis major grids 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1 Yes
majorgrid.visible Should major grids be visible see the Booleans section of "ahelp chipsopt" false Yes
majortick.color The color to use for major ticks name or hex; see the Color section of "ahelp chipsopt" default Yes
majortick.count Default number of ticks to display when major mode is count Non-negative integer 4 Yes
majortick.interval Spacing to use between ticks when major mode is interval Non-negative value 10 Yes
majortick.length length of major ticks Non-negative integer 1 Yes
majortick.mode Mode of the axis tickmark positioning arbitrary|count|interval|limits|nice; see the Tick Mode section of "ahelp chipsopt" limits Yes
majortick.style Style of the axis tickmarks inside|outside|centered; see the Tick Style section of "ahelp chipsopt" inside Yes
majortick.thickness Thickness of major ticks 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1 Yes
majortick.visible Are major ticks visible or hidden see the Booleans section of "ahelp chipsopt" true Yes
minorgrid.color Color of the axis minor grids name or hex; see the Color section of "ahelp chipsopt" default Yes
minorgrid.style stipple pattern used to draw the axis minor grids see the Line Style section of "ahelp chipsopt" dot Yes
minorgrid.thickness Thickness of the axis minor grids 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1 Yes
minorgrid.visible Should minor grids be visible see the Booleans section of "ahelp chipsopt" false Yes
minortick.color The color to use for minor ticks name or hex; see the Color section of "ahelp chipsopt" default Yes
minortick.count Default number of ticks to display when minor mode is count Non-negative integer 4 Yes
minortick.interval Spacing to use between ticks when minor mode is interval Non-negative value 10 Yes
minortick.length length of minor ticks Non-negative integer 1 Yes
minortick.mode Mode of the axis tickmark positioning arbitrary|count|interval|limits|nice; see the Tick Mode section of "ahelp chipsopt" nice Yes
minortick.style Style of the axis tickmarks inside|outside|centered; see the Tick Style section of "ahelp chipsopt" inside Yes
minortick.thickness Thickness of minor ticks 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1 Yes
minortick.visible Are minor ticks visible or hidden see the Booleans section of "ahelp chipsopt" true Yes
offset.parallel axis label offset from axis start (-.5) to axis end (.5) -0.5 to 0.5 inclusive; 0 is the center and -0.5/+0.5 refer to the edges 0 Yes
offset.perpendicular axis label offset from axis baseline in pixels -100 to 100, inclusive 40 Yes
pad The percentage of padding to add to an axis in arbitrary limits or interval modes Non-negative value 0.05 Yes
thickness Thickness of the axis 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1 Yes
tickformat print format for axis ticklabels alphanumeric; see the Tick Format section of "ahelp chipsopt" %g Yes
ticklabel.angle angle, in degrees, of the axis ticklabel -360.0 to 360.0 0 Yes
ticklabel.color Color of the axis ticklabels name or hex; see the Color section of "ahelp chipsopt" default Yes
ticklabel.font font for the axis ticklabel text helvetica|courier|times|greek; see the Font section of "ahelp chipsopt" helvetica Yes
ticklabel.fontstyle style of the axis ticklabel text normal|bold|italic|bolditalic; see the Font Style section of "ahelp chipsopt" normal Yes
ticklabel.halign Horizontal location of the string reference point of the axis ticklabel auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" center Yes
ticklabel.offset Offset of ticklabels to axis base (in pixels) Non-negative value 6 Yes
ticklabel.size Font size of the axis ticklabel 1 to 100 12 Yes
ticklabel.style Style of the axis ticklabels inside, outside outside Yes
ticklabel.valign Vertical location of the string reference point of the axis ticklabel auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" center Yes
ticklabel.visible Should ticklabels be visible see the Booleans section of "ahelp chipsopt" true No
x.label.text The text used for the X axis label A text label with limited support for LaTeX commands; see the Text Formatting section of "ahelp chipsopt". Yes
x.label.angle The angle used for the X axis label 0 is horizontal, 90 is vertical with text reading from bottom to top, and 270 is vertical with text reading from top to bottom. 0 Yes
x.stem stem used for x axis id An alpha-numeric character sequence that does not contain a space ax No
y.label.text The text used for the Y axis label A text label with limited support for LaTeX commands; see the Text Formatting section of "ahelp chipsopt". Yes
y.label.angle The angle used for the Y axis label 0 is horizontal, 90 is vertical with text reading from bottom to top, and 270 is vertical with text reading from top to bottom. 90 Yes
y.stem stem used for y axis id An alpha-numeric character sequence that does not contain a space ay No

The label.angle field

The label.angle field was removed in CIAO 4.6; the x.label.angle and y.label angle fields should be used instead.


Bugs

See the bugs pages on the ChIPS website for an up-to-date listing of known bugs.

See Also

axes
add_axis, bind_axes, current_axis, delete_axis, display_axis, display_major_ticks, display_minor_ticks, get_axis, get_xaxis, get_yaxis, hide_axis, hide_major_ticks, hide_minor_ticks, lin_scale, log_scale, move_axis, reverse_axes, set_arbitrary_tick_positions, set_xaxis, set_yaxis, shuffle_axis, unbind_axes
concepts
setget
utilities
set_current