Version 2.0
Index : Using Tick-Marks


Using Tick Marks
 

Tick marks are the small segmentation marks found on each axis, usually where the labels are situated to denote the places where the numeric or data values occur. There are 2 types of tick marks - normal, and minor ticks. Minor ticks are about half the size of normal ticks and they are used to show smaller increments on the axes. Ticks can be configured using a number of different attributes. Below is a summary. If you click on the attribute names you will be able to see more detailed information regarding the values they can take.

Ticks
TickStyle
XAxisTicks
XAxisMinorTicks
YAxisTicks
YAxisMinorTicks
TickEvery
(Turns ticks on/off for X and Y axes)
(Sets how the tick marks are displayed)
(Sets the fequency of the ticks on the X-axis)
(Sets the fequency of the minor ticks on the X-axis)
(Sets the fequency of the ticks on the Y-axis)
(Sets the fequency of the minor ticks on the Y-axis)
(Displays a tick mark at every 'n'th point)

Initialisiation & Use

If you wish to turn tick marks on and off, you would need to use the Ticks attribute. You can also use this to set which axes the tick marks will appear on. You can also set how the tick marks are displayed (ie. inside, outside, or through the axis) using the TickStyle attribute.

If we carry on from the example in the Axes tutorial, we can now use the tick marks to make the axes appear as we want them. Since an axis isn't much use without tick marks to show what the values are, we can add tick marks to the Y-axis using YAxisTicks. We also need to make sure we use the YAxisStyle attribute as well, to set the axis to 'user-defined'.

Let's set the number of ticks on the Y-axis to 5 and see what happens.

 
Using YAxisTicks to set the number of ticks on the axis
 
<CFX_GraphicsServer
ST_DataSet0="-10,5,3,-2,9,1"
GraphType="3"
YAxisMin="-30"
YAxisMax="25"
YAxisStyle="2"
YAxisTicks="5"
TickStyle="2"
>

As you can see from the graph above, the axis with the largest min/max value has been given the number of tick marks denoted by the value assigned to YAxisTicks, in this case, 5. This spaces the tick marks at 6 unit intervals since the axis min is 30. Because the tick marks on the positive and negative axis have to be the same distace apart, the tick marks on the positive axis are also set to 6 units apart. Also, because the Y-axis max is set to 25, and this doesn't divide by 6, the Y-axis max has been auto adjusted to 24, which is the nearest value that will divide by 6.

Another thing to note about the above graph is the use of TickStyle (which has been set to 2) to place the tick marks only on the outside of the X-axis.


Minor Ticks

We can also use YAxisMinorTicks to place smaller tick marks in between the main tick marks on the axis. If you take a look at the input range for YAxisMinorTicks by clicking on the link, you will see that setting YAxisMinorTicks to '1' will place 5 minor tick marks in between every major tick mark. However, we can also use negative values to denote the exact number of minor ticks required inbetween every major tick mark.

Let's set the number of minor ticks on the Y-axis to -2 and see what happens.

 
Using YAxisTicks to set the number of ticks on the axis
 
<CFX_GraphicsServer
ST_DataSet0="-10,5,3,-2,9,1"
GraphType="3"
YAxisMin="-30"
YAxisMax="25"
YAxisStyle="2"
YAxisTicks="5"
YAxisMinorTicks="-2"
>

As you can see, the graph now has 2 minor tick marks on the Y-axis for every major tick mark.


XAxisTicks and XPosData

As we saw in the Axes Tutorial, setting the axis properties of the X-axis is slightly more complicated than for the Y-axis. In order to do this we need to use the ST_XPosSet{0..} or the DB_XPosSets attributes in conjunction with the XAxisStyle and XAxisTicks attributes.

Let's have another look at an example:

 
Using XPosData to set ticks for the X-axis
 
<CFX_GraphicsServer
ST_DataSet0="10,5,3,2,9,1"
ST_XPosSet0="1,2,3,4,5,6"
GraphType="6"
XAxisMin="0"
XAxisMax="10"
XAxisStyle="2"
XAxisTicks="4"
>

As we can see from the above example, we have set ST_XPosSet0 so that each point on the graph is given an x-position value. Since we want the points on the graph to appear as normal, we have set the X-positions of these points as just 1 to 6. This then allows us to set the number of ticks on the axis to however many we want (in this case 4). Since the min/max of the axis has been set from 0 to 10, each tick mark appears every 2.5 units along the axis.

This formatting can be useful when drawing mathematical line graphs, but most of the time it is unnecessary. However, we still quite often want to change the number of tick marks on the X-axis, especially if we have a lot of points on the graph and we don't want to clutter the axis with too many tick marks. Because of this, we can use the TickEvery attribute which will automatically set the min/max, XPosData and tick marks for you. Below is an explanation of how to use this.


TickEvery

Finally, in the 'Ticks' section, we will cover the TickEvery attribute. TickEvery="n" will place a tick mark at every nth point along the axis. It can also be used in conjunction with ST_XLabels or DB_XLabelSet to add labels to the tick marks. It differs from the use of LabelEvery in that LabelEvery will just place a label on every nth tick mark, but the number of ticks will not be reduced. For more information on these attributes, please click on the relevant links.

TickEvery is used as an alternative to XAxisTicks. The difference being that TickEvery will automate the task of setting the axis limits depending on the frequency of the tick marks. It will also position the X-axis labels atumatically, so the correct labels and tick marks correspond to the correct points on the graph. There are certain limitations to using TickEvery though, such as the inability to use it with XPosSet. For more details on this, please click the TickEvery link.

As an example of TickEvery, we will create a graph to show it in action.

 
Using TickEvery
 
<CFX_GraphicsServer
ST_DataSet0="6,1,8,3,6,4,7,7,6,1"
GraphType="6"
TickEvery="4"
ST_XLabels="a,b,c,d,e,f,g,h,i,j"
>

As can be seen from the above example, there are 10 points in the graph. Since we have set TickEvery to 4, a tick mark, and label, are placed at every 4 points along the graph. However, because 4 does not divide into 10 exactly, the tick marks have been placed, with the correct label, below the relevant data points, and the axis extended to allow the appropriate spacing between the ticks. In this case, the axis has been extended to 12, because 12 is the next value divisible by 4 that is greater than 10.


[footer]