<?php
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_utils.inc.php');
$f = new FuncGenerator('cos($x)+1.5*cos(2*$x)');
list($datax,$datay) = $f->E(0,10);
$tickPositions = array();
$tickLabels = array();
$tickPositions[0] = 0;
$tickLabels[0] = '0';
for($i=1; $i/2*M_PI < 11 ; ++$i ) {
$tickPositions[$i] = $i/2*M_PI;
if( $i % 2 )
$tickLabels[$i] = $i.'/2'.SymChar::Get('pi');
else
$tickLabels[$i] = ($i/2).SymChar::Get('pi');
}
$n = count($datax);
$xmin = $datax[0];
$xmax = $datax[$n-1];
$graph = new Graph(400,200);
$graph->SetScale('linlin',0,0,$xmin,$xmax);
$graph->title->Set('Example with manual tick labels');
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$graph->xaxis->SetPos('min');
$graph->xaxis->SetMajTickPositions($tickPositions,$tickLabels);
$graph->xaxis->SetFont(FF_TIMES,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_TIMES,FS_NORMAL,10);
$graph->xgrid->Show();
$p1 = new LinePlot($datay,$datax);
$p1->SetColor('teal');
$graph->Add($p1);
$graph->Stroke();
?> |