Synopsis
Modifies the attributes of an existing x axis.
Syntax
set_xaxis(attributes) set_xaxis(id, attributes)
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_xaxis command sets the specified attributes to the provided values. The modified x axis becomes current. To modify a y axis, use the set_axis or set_yaxis command.
Customizing the Axis
There are several attributes that control the characteristics of the x-axis. The set_xaxis command may be used to modify the attribute values of an existing x-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 x-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.
Examples
Example 1
chips> set_xaxis(["color", "blue", "thickness", 2, "tickformat", "%0.0z"])
Using attribute/value pairs, set the x-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_xaxis(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_xaxis(["tickformat", "ra"])
Change the current X axis to label the axis using sexagesimal hour notation.
The following call is equivalent - assuming "ax1" is the name of the current X axis:
chips> set_axis("ax1", ["tickformat", "ra"])
Example 4
chips> set_xaxis(["*.color", "blue"])
Change all the color attributes of the X axis - such as the label and tick mark colors - to blue.
Example 5
chips> av = {} chips> av['x.label.text'] = r'\nu^\gamma' chips> av['x.label.angle'] = 45 chips> av['label.size'] = 20 chips> set_xaxis(av)
Here we set the X-axis label text, angle, and size. An angle of 45 means that the text is rotated from the X axis; the default angle for X axes is 0, i.e. parallel to the X axis.
Note that the label size does not need the "x." prefix, but the label text and angle do. As the label text contains the '\' character for LaTeX symbols, we use a r character before the string to prevent them from being used as escape characters (see the String Literal section of the Python documentation for more information).
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_xaxis("ax2", s)
Populate the "s" structure with the attribute values, then use it to set axis ax2 to have visible major grids, right-justified tick labels rotated at 45 degrees, and a steelblue baseline color.
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_axis, set_yaxis, shuffle_axis, unbind_axes
- concepts
- setget
- utilities
- set_current