<?php
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
require_once ('jpgraph/jpgraph_scatter.php');
require_once ('jpgraph/jpgraph_regstat.php');
$xdata = array(1,3,5,7,9,12,15,17.1);
$ydata = array(5,1,9,6,4,3,19,12);
$spline = new Spline($xdata,$ydata);
list($newx,$newy) = $spline->Get(50);
$g = new Graph(300,200);
$g->SetMargin(30,20,40,30);
$g->title->Set("Natural cubic splines");
$g->title->SetFont(FF_ARIAL,FS_NORMAL,12);
$g->subtitle->Set('(Control points shown in red)');
$g->subtitle->SetColor('darkred');
$g->SetMarginColor('lightblue');
$g->SetScale('linlin');
$g->xaxis->SetLabelFormat('%1.1f');
$splot = new ScatterPlot($ydata,$xdata);
$splot->mark->SetFillColor('red@0.3');
$splot->mark->SetColor('red@0.5');
$lplot = new LinePlot($newy,$newx);
$lplot->SetColor('navy');
$g->Add($lplot);
$g->Add($splot);
$g->Stroke();
?> |