Asside: Why the author chose this data format: In PGPLOT you would have the X-values in one array and the Y-values in a second. This would sometimes lead to really strange graphs if one array was accidentally one data element short. Plus most of the data the author was using came in from a database using a _get_row or _get_array (in php) and one can just pass it straight in to PHPLOT.
Colors and border colors are set by SetDataColors. Why not have colors as part of the same array? Because most data applications are used to putting out raw data and not raw data + color information.
So in PHPLOT the datalabel,x-value,y-value and error are grouped together as a value array. Then the entire set of points to be plotted is passed in as a data array E.g. Data_array = array(value_array_1,value_array_2,....)
See below for examples of the various data types:
$data = array( array("label 1",1.1,2,3,4), array("label 2",2,3,4,5), array("label 3",5,6,7,8), array("label 4",10,12,13,14) );Which will display data points at (1,1.1), (1,2), (1,3), (1,4), (2,2), (2,3)....
$data = array( array("label 1",1.1,2,3,4), array("label 2",2,3,4,5), array("label 3",5,6,7,8), array("label 4",10,12,13,14) );Notice that this is the same as in the previous example except that the x,y data points are at (1.1,2), (1.1,3), (1.1,4), (2,3)...
Example: If x values are seconds offset from the beginning of the day. This coresponds to unix timestamps on January 1, 1970, so all I had to do was $graph->SetXGridLabelType("%H:%M") to display the time properly.
The php strtotime() function also comes in handy turning dates into timestamps, especially for parameters to SetPlotAreaWorld().
Example:
$graph->SetPlotAreaWorld(strtotime("October 1"), 0,strtotime("December 15"),10);
$graph->SetXGridLabelType("time") ;
$graph->SetXTimeFormat("%b %d") ;
These functions only are availabe in the class PHPlot_data that extends PHPlot. Since all functions of that section do calculations on the data, it is neccessary that data is supplied to the class by the SetDataValues() function before calling any of the functions.