1 | <?php // content="text/plain; charset=utf-8"
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_line.php');
|
---|
4 | require_once ('jpgraph/jpgraph_utils.inc.php');
|
---|
5 |
|
---|
6 | $f = new FuncGenerator('cos($x)*$x');
|
---|
7 | list($xdata,$ydata) = $f->E(-1.2*M_PI,1.2*M_PI);
|
---|
8 |
|
---|
9 | $f = new FuncGenerator('$x*$x');
|
---|
10 | list($x2data,$y2data) = $f->E(-2,2);
|
---|
11 |
|
---|
12 | // Setup the basic graph
|
---|
13 | $graph = new Graph(450,350);
|
---|
14 | $graph->SetScale("linlin");
|
---|
15 | $graph->SetShadow();
|
---|
16 | $graph->img->SetMargin(50,50,60,40);
|
---|
17 | $graph->SetBox(true,'black',2);
|
---|
18 | $graph->SetMarginColor('white');
|
---|
19 | $graph->SetColor('lightyellow');
|
---|
20 |
|
---|
21 | // ... and titles
|
---|
22 | $graph->title->Set('Example of Function plot');
|
---|
23 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
24 | $graph->subtitle->Set("(With some more advanced axis formatting\nHiding first and last label)");
|
---|
25 | $graph->subtitle->SetFont(FF_FONT1,FS_NORMAL);
|
---|
26 | $graph->xgrid->Show();
|
---|
27 |
|
---|
28 | $graph->yaxis->SetPos(0);
|
---|
29 | $graph->yaxis->SetWeight(2);
|
---|
30 | $graph->yaxis->HideZeroLabel();
|
---|
31 | $graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
|
---|
32 | $graph->yaxis->SetColor('black','darkblue');
|
---|
33 | $graph->yaxis->HideTicks(true,false);
|
---|
34 | $graph->yaxis->HideFirstLastLabel();
|
---|
35 |
|
---|
36 | $graph->xaxis->SetWeight(2);
|
---|
37 | $graph->xaxis->HideZeroLabel();
|
---|
38 | $graph->xaxis->HideFirstLastLabel();
|
---|
39 | $graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
|
---|
40 | $graph->xaxis->SetColor('black','darkblue');
|
---|
41 |
|
---|
42 | $lp1 = new LinePlot($ydata,$xdata);
|
---|
43 | $lp1->SetColor('blue');
|
---|
44 | $lp1->SetWeight(2);
|
---|
45 |
|
---|
46 | $lp2 = new LinePlot($y2data,$x2data);
|
---|
47 | list($xm,$ym)=$lp2->Max();
|
---|
48 | $lp2->SetColor('red');
|
---|
49 | $lp2->SetWeight(2);
|
---|
50 |
|
---|
51 |
|
---|
52 | $graph->Add($lp1);
|
---|
53 | $graph->Add($lp2);
|
---|
54 | $graph->Stroke();
|
---|
55 |
|
---|
56 | ?>
|
---|
57 |
|
---|
58 |
|
---|