(Defined in: jpgraph_scatter.php : 65)
Class usage and Overview
A variant of scatter plot is the so called Field Plots this is
basically a scatter plot where each scatter point is an arrow with a
direction between 0 to 359 degrees. This effectively allows the
visualization of 3 parameters at each point (x,y,angle). As an
additional bonus there is also possible to define a callback for each
scatter plot to also define the color for each point.
See also related classes:
FieldArrow
Class Methods
Specify callback for each arrow in the field plot
Argument | Default | Description |
$aFunc
| | Function name |
Description:
Specify a callback that gets clled for each arrow in the field plot
The callback should return an array with the elements
- Color
- Size of arrow (in pixels)
- Arrow head size (as integer between0 and 9)
// Gradient. Make the arrows red at the pole and colder (blue)
// teh further we get from the pole
function FldCallback($x,$y,$a) {
$polex=4;
$poley=40;
$maxr = 3000;
// Size and arrow size is constant
$size="";
$arrowsize="";
// Since we have different scales we need the data points
// to be of the same magnitude to give it a distance
// interpretation.
$x *= 10;
// Colors gets colder the further out we go from the center
$r = ($x-$polex*10)*($x-$polex*10)+($y-$poley)*($y-$poley);
$f = $r/$maxr;
if( $f > 1 ) $f=1;
$red = floor((1-$f)*255);
$blue = floor($f*255);
$color = array($red,0,$blue);
return array($color,$size,$arrowsize);
}
// Setup the field plot
$fp = new FieldPlot($datay,$datax,$angle);
// Setup formatting callback
$fp->SetCallback('FldCallback');
Create an instance of FieldPlot
Argument | Default | Description |
$datay
| | Y-coordinate |
$datax
| | X-coordinate |
$angles
| | Angle |
Description:
Create a new instance of a field plot
$fp = new FieldPlot($datay,$datax,$angle);