To set the tics of an axis, you can proceed as follows (where aptr is a pointer to an axis):
aptr->tics(); // clears all tic settings aptr->tics(1.5); // sets equidistant tics, with distance 1.5 aptr->tics(2.4,"label"); // adds a tic to the axis at 2.4, with the label 'label' aptr->tics(1.5,0,10); // sets equidistant tics with distance 1.5, beginning from 0 // and not extending over 10
These can be included in one statement as well. The following code first clears all previous tic settings, then sets equidistant tics, and adds some extra tics at fixed positions:
aptr->tics()(2,0,10)(3,"{\\Large 3}")(5,"{\\Large 5}");
The most frequent application would be: frame::current().x1axis()->tics()(...)(...)(...); To save the user from typing so much, the tics of the axes of the current frame can be set easier (demonstrated for the x1 axis, which is the lower horizontal axis. Figure out, how it works for other axes).
set::x1tics()(2,0,10)(3,"{\\Large 3}")(5,"{\\Large 5}");
Major tics Major tics are those which receive a label as well (i.e. where the value on the axis is displayed)
There are two ways how axis tics can be specified:
To specify equidistant tics one can specify the following 3
parameters for an axis, optionally: the distance between two
neighbouring tics, the first tic value, and the upper limit for the
tics. Any of these can be set to 'unset', and in this case the
unspecified values are calculated automatically. For example to set up
xtics with a distance of 1, beginning at 3, up to the axis maximum,
say:
x1tics(1,3,unset);
(note that you can not say x1tics(1,3), because this would
put a single tic at the value 1, with the label "3").
To specify explicit tics one has to provide the axis value, at which the tic will be drawn, and the label, which will appear.
The algorithm to draw tics is as follows:
If equidistant tics are drawn, the unset parameters are calculated at the time the axis is printed to a terminal. That is, for example if only the distance of these tics is specified, the lower and upper limits for the set of equidistant tics will be calculated from the final range of the axis.
The axis class declares the nested class tic_setter, and has a member of this type, called tics. The parenthesis operators with 0, 1, 2 and 3 arguments can be called on this member, which perform the above-mentioned tasks. These operators all return a reference to the same object, therefore the parenthesis operators can be called subsequently on it, making the interface user-friendly, as shown at the top of page in the practical guide. (Currently cint fails to interpret the subsequent calls of the () operator, so this is a too early documentation...). See below the excerpt from the source code for the explanation, what these operators do.
For the user's convenience another class (with the same name: tic_setter) is declared in a higher scope (within namespace blop), which has the same set of parenthesis operators. Four 'global' (in namespace blop) instances of this class (x1tics, y1tics, x2tics, y2tics) are defined, and calling the parenthesis operators on them applies the settings to the four axes of the current frame respectively. For example:
x1tics()(2,0,20)(3,"{\\blue 3}");
Minor tics Minor tics are smaller tics which do not display the value on the axis; they are only used to subdivide the interval between major tics.
Some examples
set::n_minor_tics(5); // Set the number of sub-intervals between major tics to 5 on the x1 and y1 axis set::n_minor_tics_x1(5); // Do it for only the x1 axis, etc. frame::current().x1axis()->n_minor_tics(5); // Same as the previous set::grid_at_minor_tics(axis::x1|axis::y1); // Draw gridlines at minor tics as well for these axes set::grid_at_minor_tics(true); //Same as the previous line
class axis { public: ... class tic_setter { public: ... tic_setter &operator()(); // 0 args ==> clear all tics tic_setter &operator()(var distance); // 1 args ==> set distance for equidistant tics tic_setter &operator()(var dist, var from, var to); // 3 args ==> set distance and limits for equidistant tics tic_setter &operator()(var pos, var label); // 2 args ==> set explicit tic }; tic_setter tics; }; class tic_setter { public: tic_setter(int i); tic_setter &operator()(); tic_setter &operator()(var); tic_setter &operator()(var,var); tic_setter &operator()(var,var,var); }; extern tic_setter x1tics, y1tics, x2tics, y2tics;