Table of Contents
With cartesian graphs we refer to all plots which have orthogonal x and y axis. The library support the option of multiple y-scales (when applicable) but only on x-axis can be used.
The following principle linear graph types are supported as of v2.5 (note that some graph types may have additional subtypes that are not shown in this overview.)
Figure 14.1. Supported principle linear graph types in the library
a) Line plot (See Section 15.1.1) |
b) Area plot (See Section 15.1.10) |
c) Bar plot (See Section 15.2) |
a) Field plot (See Section 15.5.3) |
b) Error plot (See Section 15.3) |
c) Stock plot (See Section 15.4) |
a) Geo-map plot (See Section 15.5.5) |
b) Impuls (stem) plot (See Section 15.5) |
c) Spline plot (See Section 15.1.15) |
a) Balloon plot (See Section 15.5.4) |
b) Scatter plot (See Section 15.5) |
c) Contour plot (See Section 15.6) |
Each of these graph types have there own section where more details can be found by following the link under the corresponding graph icon.
The x and y axis each in a graph has an associated scale, labels, titles, grid lines, colors and position. The axis properties are accessed as objects of the axis instance variables in the main graph class. The axis can be access vi the following instance variables.
Graph::xaxis
, The x-axis, (by default on the
bottom)
Graph::yaxis
, The y-axis, (by default on the left
side)
Graph::y2axis
, The second y-axis (by default on the
right side)
In addition the library also supports the use of multiple y-axis and they are accessed via an instance array
Graph::ynaxis[]
All axis in turn are instances of class Axis
and hence share
common properties. The only two property that can be publicly accessed on the
axis are
Axis::scale
. The scale of the axis. An instance of
either LinearScale
, LogScale
or
DateScale
. This rarely needs to be accessed
directly.
Axis::title
. The axis title. On the x-axis this is
horizontal by default and on the y-axis the title is vertical by
default
On the other hand there are a large amount of methods that can be used on the axis to adjust various properties. Some examples of commonly used methods are given below. The full description of each method is given in the API reference.
Adjusting the labels
Axis::SetLabelFormatString($aFormat,
$aIsDateFormat=false)
Axis::SetLabelFormatCallback($aCallbackFunc)
Axis::SetLabelAlign($aHorAlign,
$aVertAlign='top',$aParagraphAlign='left')
Axis::HideLabels($aHide=true)
Axis::SetTicklabels($aLabels,
$aLabelColors=null)
Axis::SetLabelMargin($aMargin)
Axis::SetLabelSide($aSide)
Axis::SetFont($aFamily,$aStyle=FS_NORMAL,$aSize=10)
Axis::SetLabelAngle($aAngle)
Adjusting the tick marks
Axis::SetTickSide($aSide)
Axis::SetTickPositions($aMajPos,$aMinPos=NULL,$aLabels=NULL)
Axis::HideTicks($aHide)
Adjusting the actual axis
Axis::HideLine($aHide=true)
Axis::Hide($aHide)
Axis::SetWeight($aWeight)
Axis::SetPos($aPositionOnOtherScale)
Adjusting the title
Axis::SetTitle($aTxt)
Axis::SetTitleMargin($aMargin)
Axis::SetTitleSide($aSide)
Axis::SetColor($aColor)
The above methods are valid for all possible axis. So for example the following line sets the font for the labels on the x-axis
1 | $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,12); |
and the follwing code set the font for the y-axis
1 | $graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,12); |
The two major ways to adjust the look and feel of the axis are adjustments of the color and the weight (i.e. width) and this can be done with the appropriate methods.
Grid lines will make it easier to see where the data points are in the graph.
The grid lines are access by the properties "xgrid
" and
"ygrid
"of the Graph class. By default only the y-axis grid are
enabled by default. The following code example enables the major grids for both
the x- and y-axis.
1 2 | $graph_>xgrid->Show();
$graph->ygrid->Show(); |
The grid lines are instances of Class Grid
. and supports the
following methods
Grid::SetColor($aMajColor,$aMinColor=false)
Grid::Show($aMajGid=true,$aMinGrid=false)
Grid::SetLineStyle($aType)
This method makes it
possible to adjust the line style of the grid lines. The line style
is specified as a string and can have one of the following
values
"solid"
"dotted"
"dashed"
"longdashed"
Grid::SetFill($aFlg=true,$aColor1='lightgray',$aColor2='lightblue')
The last method needs an explanation. The fill refers to the possibility to fill the space between the grid lines with alternating colors as specified in the method call. Figure 14.2 shows an example on how this can be used to make it easier to read a plot.
In the above example we have also used the possibility of using alpha-blending (for example on the shadow on the legend box).
In order to make it easier to setup a couple of typical axis configuration used in science plots there are four predefined configurations as shown in Figure 14.3.
Figure 14.3. Predefined scientific axis positions
![]() |
![]() |
![]() |
![]() |
AXSTYLE_BOXOUT | AXSTYLE_BOXIN | AXSTYLE_YBOXIN | AXSTYLE_YBOXOUT |
The styles can easily be setup with a call to the method
Graph::SetAxisStyle($aStyle)
An example of using this setup of the axis is shown in Figure 14.4
The axis can be manually positioned with a call to
Axis::SetPos()
The position given is the scale position on the "other"axis, i.e. for the x-axis the position specifies the crossing of the y-axis and vice versa.
Since it is possible to manually specify all aspects of the axis the table below shows some typical common setups and the principle calls needed to achieve the illustrated affect.
Table 14.1. Axis configurations
|
This is the default setup and not extra configurations are needed and it is the same as
| ||
|
This setup is configured by moving the x-axis to the top
| ||
|
This is the standard style but with an added box around the plot area.
| ||
|
| ||
|
This configuration locks the x- and y-axis at the origin
| ||
|
With an added box around the plot area
|