Last modified: December 2013

URL: https://cxc.cfa.harvard.edu/chips/ahelp/set_arbitrary_tick_positions.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.11 ChIPS v1

set_arbitrary_tick_positions

Context: axes

Synopsis

Change the position and labels for the major tickmarks on an axis

Syntax

set_arbitrary_tick_positions(pos)
set_arbitrary_tick_positions(pos, labels)
set_arbitrary_tick_positions(id, pos)
set_arbitrary_tick_positions(id, pos, labels)

Description

The function arguments.

Argument Description
pos An array of data coordinates indicating where the major tick marks should be drawn.
labels An array of labels to be used instead of the data value. If given it must have the same length as the pos array. The values need not be strings, since str() will be used to convert the values if required.
id A ChipsId structure indicating which axis to change, or a string containing the axis name (e.g. 'ax1').

The set_arbitrary_tick_positions command specifies the location of major tickmarks when the majortick mode is set to "arbitrary". Additionally, the call may be used to specify string labels instead of numeric labels.

By default, set_arbitrary_tick_positions operates on the current x and y axes. If the user specifies a specific axis, either via a ChipsId object or an axis label string, only the specified axis is modified. The call does two things:

The limits are not adjusted by this call; only tick locations within the limits of the displayed axis range appear on the screen. If the user adjusts the limits, the arbitrary positions within the limits are displayed. Note that when displaying arbitrary ticks, no tick marks (major or minor) will appear outside of the range of provided abritrary locations. For instance, if set_arbitrary_tick_positions is called with values [5,10,15,20] but the axis data limits run from 7 to 40, then there will be no ticks from 20 to 40.

The display of tickmarks on axes is controlled by the tick mode of the axis. If the mode is set to 'arbitrary', tick marks will only be displayed in the range of set arbitrary tick positions. Data limits do not adjust during a change in tick mode.

In addition to allowing the user to specify the locations of tick marks, this command is also used to allow the user to set alpha-numeric labels. To use text for tick mark labels, two arrays are supplied to this routine. The first array contains the locations of where the major tick marks should be placed. The second array contains the strings to use at each tick mark location. The two arrays must contain the same number of elements. To have a tickmark without a corresponding label, an empty string is used in the second array (ie. "").


Examples

Example 1

chips> x = [1,2,3,4,5,6,7]
chips> xl = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
chips> y = [3,2,1,4,0,1,2]
chips> add_histogram(y, ["dropline", True, "fill.style",
"downdiagonal"])
chips> set_arbitrary_tick_positions("ax1", x, xl)
chips> set_xaxis("ax1", ["minortick.visible", False])

Creates a histogram with seven bins and then changes the X axis major tick labels to be strings specifying days of the week and hide the minor tick marks.

Example 2

chips> clear()
chips> add_contour([4,9,3,2], 2, 2, ["axis.minortick.visible", False])
chips> set_arbitrary_tick_positions([1.13,1.47,1.73,1.81,2.04])

Here we create a contour plot and then adjust the ticks on both axes to appear at the values 1.13, 1.47, 1.73 and 1.81. Since the image covers the axis range 1 to 2 the final value, at 2.04, is not shown unless the limits are increased:

chips> limits(X_AXIS, 0.8, 2.2)

This changes both axes since the creation of a contour plot forced the plot to have its data-aspect ratio set.

For more information on aspect ratios, refer to "ahelp aspectratio".

Example 3

chips> x = np.arange(5)
chips> y = x**3
chips> add_curve(x, y, ["symbol.style", "none"])
chips> log_scale(Y_AXIS)
chips> yl = [1, 2, 5, 10, 20, 50]
chips> set_arbitrary_tick_positions("ay1", yl)
chips> set_yaxis(["minortick.visible", False])

Here we add labels to a log-scale axis, turning off the minor tick marks since they are not informative.

Example 4

chips> p = [10.23, 47.5, 89.8, 102.3]
chips> l = [1, "2", None, "last"]
chips> set_arbitrary_tick_positions("ax1", p, l)

In this very-contrived example, we add labels at x = 10.23, 47.5, 89.8 and 102.3. The labels for these are converted to strings from the input values, so will be displayed as: "1", "2", "None" and "last" (without the quotation marks). The following command would create the same result:

chips> set_arbitrary_tick_positions("ax1", p, [str(ll) for l in l])

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_axis, set_xaxis, set_yaxis, shuffle_axis, unbind_axes
concepts
setget
utilities
set_current