As you saw in the previous example it is possible to use different types of scales. In JpGraph you can use the following scales

- Linear scale, the standard "scale"
- Logarithmic scale
- Integer scale, very similar to linear scale but restricts the scale values (and labels) to integer values.
- Text scale, Similar to integer scale and used when only the numbering of items is relevant. A text scale is almost exclusively used for the X-axis. A typical example for this is the X-axis for a bar plot. The labels for the text scale is usually replaced by user supplied texts. Text scales can only be used for the X-axis (it doesn't make sense for the Y-scale).

Any combination of these may be used. Linear and logarithmic scales are pretty straightforward. The text scale might deserve some explanation. The easiest way to think of the text scale is as a linear scale consisting of only natural numbers, i.e. 0,1,2,3,4,... . This scale is used when you just have a number of Y-values you want to plot in a consecutive order and don't care about the X-values. For the above example it will also work fine to use a linear X-scale (try it!). However, the scale is now treated as consisting or real numbers so the auto scaling, depending on the size of the image an the number of data points, might decide to display other labels then the natural numbers., i.e. a label might be 2.5 say. This is not going to happen if you use a text scale.

The normal practice for text scale is to specify text strings as labels instead as the default natural numbers. You can specify text strings for the labels by calling the SetTickLabels() method on the Axis.

To specify the scale you use the SetScale() method. A few examples might help clarify this.

- "textlin", text-scale for X-axis, Linear scale for Y-axis
- "linlin", linear-scale for X-axis, Linear scale for Y-axis
- "linlog", linear-scale for X-axis, Logarithmic scale for Y-axis
- "loglog", Logarithmic scale for X-axis, Logarithmic scale for Y-axis
- "textint", text-scale for X-axis, Integer scale for Y-axis
- "textlog", Text scale for X-axis, Logarithmic scale for Y-axis

As you can see all your graphs will require at least one call to SetScale() in the beginning of your script. Normally it will come right after the creation of the Graph().

To specify the scale for the Y2 axis you use the SetY2Scale() Since you only specify one axis you only specify "half" of the string in the previous examples. So to set a logarithmic Y2 scale you will call SetY2Scale("log");'; ShowCodeSnippet($t); ?>

Contents Previous Next