next up previous contents index
Next: Xyplane Up: Set-show Previous: Xrange   Contents   Index


Xtics

Fine control of the major (labelled) tics on the x axis is possible with the set xtics command. The tics may be turned off with the unset xtics command, and may be turned on (the default state) with set xtics. Similar commands control the major tics on the y, z, x2 and y2 axes.

Syntax:

     set xtics {axis | border} {{no}mirror}
               {in | out} {scale {default | <major> {,<minor>}}}
               {{no}rotate {by <ang>}} {offset <offset> | nooffset}
               {add}
               {  autofreq
                | <incr>
                | <start>, <incr> {,<end>}
                | ({"<label>"} <pos> {<level>} {,{"<label>"}...) }
               { font "name{,<size>}" }
               { textcolor <colorspec> }
     unset xtics
     show xtics

The same syntax applies to ytics, ztics, x2tics, y2tics and cbtics.

axis or border tells gnuplot to put the tics (both the tics themselves and the accompanying labels) along the axis or the border, respectively. If the axis is very close to the border, the axis option will move the tic labels to outside the border. The relevant margin settings will usually be sized badly by the automatic layout algorithm in this case.

mirror tells gnuplot to put unlabelled tics at the same positions on the opposite border. nomirror does what you think it does.

in and out change the tic marks to be drawn inwards or outwards.

With scale, the size of the tic marks can be adjusted. If 5#5minor6#6 is not specified, it is 0.5*5#5major6#6. The default size 1.0 for major tics and 0.5 for minor tics is requested by scale default.

rotate asks gnuplot to rotate the text through 90 degrees, which will be done if the terminal driver in use supports text rotation. norotate cancels this. rotate by 5#5ang6#6 asks for rotation by 5#5ang6#6 degrees, supported by some terminal types.

The defaults are border mirror norotate for tics on the x and y axes, and border nomirror norotate for tics on the x2 and y2 axes. For the z axis, the {axis 4#4 border} option is not available and the default is nomirror. If you do want to mirror the z-axis tics, you might want to create a bit more room for them with set border.

The 5#5offset6#6 is specified by either x,y or x,y,z, and may be preceded by first, second, graph, screen, or character to select the coordinate system. 5#5offset6#6 is the offset of the tics texts from their default positions, while the default coordinate system is character. See coordinates (p. [*]) for details. nooffset switches off the offset.

Example:

Move xtics more closely to the plot.

     set xtics offset 0,graph 0.05

set xtics with no options restores the default border or axis if xtics are being displayed; otherwise it has no effect. Any previously specified tic frequency or position {and labels} are retained.

Positions of the tics are calculated automatically by default or if the autofreq option is given; otherwise they may be specified in either of two forms:

The implicit 5#5start6#6, 5#5incr6#6, 5#5end6#6 form specifies that a series of tics will be plotted on the axis between the values 5#5start6#6 and 5#5end6#6 with an increment of 5#5incr6#6. If 5#5end6#6 is not given, it is assumed to be infinity. The increment may be negative. If neither 5#5start6#6 nor 5#5end6#6 is given, 5#5start6#6 is assumed to be negative infinity, 5#5end6#6 is assumed to be positive infinity, and the tics will be drawn at integral multiples of 5#5incr6#6. If the axis is logarithmic, the increment will be used as a multiplicative factor.

If you specify to a negative 5#5start6#6 or 5#5incr6#6 after a numerical value (e.g., rotate by 5#5angle6#6 or offset 5#5offset6#6), the parser fails because it subtracts 5#5start6#6 or 5#5incr6#6 from that value. As a workaround, specify 0-5#5start6#6 resp. 0-5#5incr6#6 in that case.

Example:

     set xtics border offset 0,0.5 -5,1,5

Fails with 'invalid expression' at the last comma.
     set xtics border offset 0,0.5 0-5,1,5

or
     set xtics offset 0,0.5 border -5,1,5

Sets tics at the border, tics text with an offset of 0,0.5 characters, and sets the start, increment, and end to -5, 1, and 5, as requested.

The set grid options 'front', 'back' and 'layerdefault' affect the drawing order of the xtics, too.

Examples:

Make tics at 0, 0.5, 1, 1.5, ..., 9.5, 10.

     set xtics 0,.5,10

Make tics at ..., -10, -5, 0, 5, 10, ...

     set xtics 5

Make tics at 1, 100, 1e4, 1e6, 1e8.

     set logscale x; set xtics 1,100,1e8

The explicit ("5#5label6#6" 5#5pos6#6 5#5level6#6, ...) form allows arbitrary tic positions or non-numeric tic labels. In this form, the tics do not need to be listed in numerical order. Each tic has a position, optionally with a label. Note that the label is a string enclosed by quotes. It may be a constant string, such as "hello", may contain formatting information for converting the position into its label, such as "%3f clients", or may be empty, "". See set format (p. [*]) for more information. If no string is given, the default label (numerical) is used.

An explicit tic mark has a third parameter, the "level". The default is level 0, a major tic. A level of 1 generates a minor tic. If the level is specified, then the label must also be supplied.

Examples:

     set xtics ("low" 0, "medium" 50, "high" 100)
     set xtics (1,2,4,8,16,32,64,128,256,512,1024)
     set ytics ("bottom" 0, "" 10, "top" 20)
     set ytics ("bottom" 0, "" 10 1, "top" 20)

In the second example, all tics are labelled. In the third, only the end tics are labelled. In the fourth, the unlabeled tic is a minor tic.

Normally if explicit tics are given, they are used instead of auto-generated tics. Conversely if you specify set xtics auto or the like it will erase any previously specified explicit tics. You can mix explicit and auto- generated tics by using the keyword add, which must appear before the tic style being added.

Example:

     set xtics 0,.5,10
     set xtics add ("Pi" 3.14159)

This will automatically generate tic marks every 0.5 along x, but will also add an explicit labeled tic mark at pi.

However they are specified, tics will only be plotted when in range.

Format (or omission) of the tic labels is controlled by set format, unless the explicit text of a label is included in the set xtics ("5#5label6#6") form.

Minor (unlabelled) tics can be added automatically by the set mxtics command, or at explicit positions by the set xtics ("" 5#5pos6#6 1, ...) form.

In case of timeseries data, position values must be given as quoted dates or times according to the format timefmt. If the 5#5start6#6, 5#5incr6#6, 5#5end6#6 form is used, 5#5start6#6 and 5#5end6#6 must be given according to timefmt, but 5#5incr6#6 must be in seconds. Times will be written out according to the format given on set format, however.

Examples:

     set xdata time
     set timefmt "%d/%m"
     set format x "%b %d"
     set xrange ["01/12":"06/12"]
     set xtics "01/12", 172800, "05/12"


     set xdata time
     set timefmt "%d/%m"
     set format x "%b %d"
     set xrange ["01/12":"06/12"]
     set xtics ("01/12", "" "03/12", "05/12")

Both of these will produce tics "Dec 1", "Dec 3", and "Dec 5", but in the second example the tic at "Dec 3" will be unlabelled.


next up previous contents index
Next: Xyplane Up: Set-show Previous: Xrange   Contents   Index
Ethan Merritt 2007-03-03