Class FieldPlot Extends Plot
(Defined in: jpgraph_scatter.php : 65)
 
 FieldPlot  Plot 
 SetCallback() 
 __construct() 
 HideLegend() 
 PreScaleSetup() 
 SetCenter() 
 SetColor() 
 SetCSIMTargets() 
 SetLegend() 
 SetLineWeight() 
 

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

 

FieldPlot ::
SetCallback($aFunc)
Specify callback for each arrow in the field plot

ArgumentDefaultDescription
$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
  1. Color
  2. Size of arrow (in pixels)
  3. Arrow head size (as integer between0 and 9)
 

Example:

// 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 $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');

 

FieldPlot ::
__construct($datay, $datax, $angles)
Create an instance of FieldPlot

ArgumentDefaultDescription
$datay  Y-coordinate
$datax  X-coordinate
$angles  Angle

Description:
Create a new instance of a field plot 

Example:

$fp = new FieldPlot($datay,$datax,$angle);