About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 9 July 2009

URL: http://cxc.harvard.edu/chips4.1/gallery/axes.sl.html

Gallery: Axis styles and grids (S-Lang)

Examples


The default plot style is to show all four axes (closed)

[ChIPS output]
Postscript version
add_curve("atan.fits[cols X,Y]",{"symbol.style","none"});

The open plot style only displays two axes

[ChIPS output]
Postscript version
variable plt = ChipsPlot;
plt.style = "open";
variable crv = ChipsCurve;
crv.symbol.style = "none";
add_curve("atan.fits[cols X,Y]",[plt,crv]);

An alternative way of saying this in one command is:

add_curve("atan.fits[cols X,Y]", {"plot.style", "open", "symbol.style", "none"});

The boxed plot style draws a box around the plot

[ChIPS output]
Postscript version
variable plt = ChipsPlot;
plt.style = "boxed";
variable crv = ChipsCurve;
crv.symbol.style = "none";
add_curve("atan.fits[cols X,Y]",[plt,crv]);

% We hide the axes to show the box surrounding the plot
hide_axis;

set_plot({"leftmargin",0.1,"bottommargin",0.1});

Although the axes have been hidden, the data is still displayed and the data range can still be changed; after the limits call below the plot changes to display the new range.


Numeric labels (ticklabels) on all four axes

[ChIPS output]
Postscript version
add_curve("atan.fits[cols X,Y]",{"symbol.style","none"});

set_plot({"rightmargin",0.15});

set_axis("all",{"ticklabel.visible",1,"ticklabel.offset",10});

The plot created by the add_curve call contains two axes: the X axis (ax1) at the bottom of the plot and the Y axis (ay1) at the left of the plot. There are also four borders which run along the edges of the plot: it is these that are controlled by the plot.style attribute, although you generally do not see the bx1 and by1 borders since they are hidden by the axes.

These borders are set up to automatically mirror the main axes; they are bound to ax1 or ay1 so that any changes to the limits, scaling, or tickmarks in the axes are also applied to the borders. This can be seen if you use the info_bound_axes call, which returns:

chips> info_bound_axes;
Window [win1]
  Frame [frm1]
    plot1:bx1   ->   plot1:bx2
    plot1:by1   ->   plot1:by2
    plot1:ax1   ->   plot1:bx2
    plot1:ay1   ->   plot1:by2

This says that the top and bottom borders (bx1 and bx2) are bound to each other and then to the X axis (ax1), and that the left and right borders (by1 and by2) are similarly bound to the Y axis (ay1).

The properties of borders can be changed using the set_axis call, either explicitly by giving a name - e.g.

set_xaxis("bx2", {"ticklabel.color", "green"});

or implicitly by the use of the "all" value, as done in this example.

Unlike other ChIPS objects, borders can not be created nor can their names be changed. They are included in the output of info as shown below:

chips> info;
Window [win1]
  Frame [frm1]
    Plot [plot1]   (0.15,0.15)  .. (0.85,0.90)
      Border bottom [bx1]  top [bx2]  left [by1]  right [by2]
      X Axis [ax1]
      Y Axis [ay1]
      Curve [crv1]

Changes in CIAO 4.1

  • The axis ticklabel.offset attribute can now be set using add_axis, set_axis, and in the ChipsAxis structure. It is therefore no longer necessary to use the low-level set_axis_ticklabel_offset() routine to change this attribute.

  • The axis ticklabel.visible attribute can now be set using add_axis, set_axis, and in the ChipsAxis structure. It is therefore no longer necessary to use the low-level set_axis_ticklabel_visible() routine to change this attribute.


Rotating the numbers along an axis

[ChIPS output]
Postscript version
add_curve("aspect.fits[cols ra,dec]",{"symbol.style","none"});

set_xaxis({"ticklabel.angle",40.0,"ticklabel.offset",16});

The properties of an axis can be found using one of the get_xaxis, get_yaxis, or get_axis routines. Here we display the X axis attributes after creating the plot above:

chips> get_xaxis;
automax = True
automin = True
color = default
depth = 100
id = None
label.angle = 0.0
label.color = default
label.font = helvetica
label.fontstyle = normal
label.halign = 0.5
label.size = 14
label.valign = 0.0
label.visible = True
majorgrid.color = default
majorgrid.style = 6
majorgrid.thickness = 1.0
majorgrid.visible = False
majortick.color = default
majortick.count = 6
majortick.interval = 10.0
majortick.length = 4
majortick.mode = limits
majortick.style = inside
majortick.thickness = 1.0
majortick.visible = True
minorgrid.color = default
minorgrid.style = 2
minorgrid.thickness = 1.0
minorgrid.visible = False
minortick.color = default
minortick.count = 3
minortick.interval = 5.0
minortick.length = 2
minortick.mode = count
minortick.style = inside
minortick.thickness = 1.0
minortick.visible = True
offset.parallel = 0.0
offset.perpendicular = 40.0
pad = 0.05
thickness = 1.0
tickformat = %g
ticklabel.angle = 40.0
ticklabel.color = default
ticklabel.font = helvetica
ticklabel.fontstyle = normal
ticklabel.halign = -99.0
ticklabel.offset = 16
ticklabel.size = 12
ticklabel.style = outside
ticklabel.valign = -99.0
ticklabel.visible = True
tickstyle = inside
x.label = None
x.stem = None
y.label = None
y.stem = None

Changes in CIAO 4.1

  • The axis ticklabel.offset attribute can now be set using add_axis, set_axis, and in the ChipsAxis structure. It is therefore no longer necessary to use the low-level set_axis_ticklabel_offset() routine to change this attribute.


Changing the format used to display the labels

[ChIPS output]
Postscript version
add_curve("aspect.fits[cols time,roll]",{"symbol.style","none"});

set_plot({"bottommargin",0.25});

set_yaxis({"tickformat","%.3f"});

variable ax = ChipsAxis;
ax.tickformat = "%.5z";
ax.ticklabel.angle = 40.0;
ax.ticklabel.offset = 30;
set_xaxis(ax);

set_axis({"ticklabel.fontstyle","bolditalic"});

Axes can be labelled in a number of ways: there are a variety of formats that can be used - including sexagesimal notation - and the arrangement of major and minor tick marks can be adjusted, as shown in later examples (mode=interval and mode=count).

Changes in CIAO 4.1

  • The axis ticklabel.offset attribute can now be set using add_axis, set_axis, and in the ChipsAxis structure. It is therefore no longer necessary to use the low-level set_axis_ticklabel_offset() routine to change this attribute.


Using sexagesimal notation for the axis labels

[ChIPS output]
Postscript version
add_curve("aspect.fits[cols ra,dec]",{"symbol.style","none"});

set_xaxis({"tickformat","ra"});
set_yaxis({"tickformat","dec"});

Changing the number of major tick marks (using mode=interval)

[ChIPS output]
Postscript version
add_curve("aspect.fits[cols ra,dec]",{"symbol.style","none"});

set_xaxis({"majortick.interval",5.0e-3,"majortick.mode","interval"});

variable ay = ChipsAxis;
ay.majortick.interval = 2.0e-3;
ay.majortick.mode = "interval";
ay.minortick.count = 3;
set_yaxis(ay);

Changing the number of major tick marks (using mode=count)

[ChIPS output]
Postscript version
add_curve("aspect.fits[cols ra,dec]",{"symbol.style","none"});

set_axis({"majortick.count",4,"majortick.mode","count"});

% Override the minortick.count setting for the Y axis
set_yaxis({"minortick.count",3});

Displaying a grid at the major tick mark locations

[ChIPS output]
Postscript version
add_curve("atan.fits[cols X,Y]",{"symbol.style","none"});

set_axis({"majorgrid.visible",1,"majorgrid.style","dot"});

Add a grid at the major and minor tick mark locations

[ChIPS output]
Postscript version
variable crv = ChipsCurve;
crv.symbol.style = "none";
crv.line.thickness = 2;
crv.line.color = "red";
add_curve("atan.fits[cols X,Y]",crv);

variable ax = ChipsAxis;
ax.majortick.mode = "interval";
ax.majortick.interval = 10.0;
ax.minortick.count = 1;
set_xaxis(ax);
variable ay = ChipsAxis;
ay.majortick.mode = "interval";
ay.majortick.interval = 1.5;
ay.minortick.count = 2;
set_yaxis(ay);
set_axis({"majorgrid.visible",1,"minorgrid.visible",1});

limits(Y_AXIS,-1.6,1.6);

In this example we have created grid lines at the major and minor tick-mark locations. We use different line styles to improve visibility, and adjusted the spacing to the major and minor tick marks so as to change the grid spacing.


Grids work with logarithmically-scaled axes too [New]

[ChIPS output]
Postscript version
add_curve("atan.fits[cols x,y]");
variable crv = ChipsCurve;
crv.symbol.style = "circle";
crv.line.style = "noline";
crv.symbol.color = "orange";
set_curve(crv);

log_scale(X_AXIS);
limits(Y_AXIS,0.0,AUTO);

set_axis({"majorgrid.visible",1,"minorgrid.visible",1});
set_yaxis({"majortick.mode","interval","majortick.interval",0.5});
set_axis({"minorgrid.color","blue"});

Grids can be displayed even when the axis is displayed using a logarithmic scale. Since there are separate majorgrid.color and minorgrid.color attributes, you can color them differently; if set_xaxis or set_yaxis had been used instead of set_axis for the last command then only the minor grid lines for that axis would have been colored blue.

Last modified: 9 July 2009


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.