source: trunk/xgraph/jpgraph/Examples/example6.1.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 1.5 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_line.php');
4
5$ydata = array(11,3,8,12,5,1,9,13,5,7);
6$y2data = array(354,200,265,99,111,91,198,225,293,251);
7
8// Create the graph and specify the scale for both Y-axis
9$graph = new Graph(300,240);   
10$graph->SetScale("textlin");
11$graph->SetY2Scale("lin");
12$graph->SetShadow();
13
14// Adjust the margin
15$graph->img->SetMargin(40,40,20,70);
16
17// Create the two linear plot
18$lineplot=new LinePlot($ydata);
19$lineplot2=new LinePlot($y2data);
20
21// Add the plot to the graph
22$graph->Add($lineplot);
23$graph->AddY2($lineplot2);
24$lineplot2->SetColor("orange");
25$lineplot2->SetWeight(2);
26
27// Adjust the axis color
28$graph->y2axis->SetColor("orange");
29$graph->yaxis->SetColor("blue");
30
31$graph->title->Set("Example 6.1");
32$graph->xaxis->title->Set("X-title");
33$graph->yaxis->title->Set("Y-title");
34
35$graph->title->SetFont(FF_FONT1,FS_BOLD);
36$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
37$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
38
39// Set the colors for the plots
40$lineplot->SetColor("blue");
41$lineplot->SetWeight(2);
42$lineplot2->SetColor("orange");
43$lineplot2->SetWeight(2);
44
45// Set the legends for the plots
46$lineplot->SetLegend("Plot 1");
47$lineplot2->SetLegend("Plot 2");
48
49// Adjust the legend position
50$graph->legend->SetLayout(LEGEND_HOR);
51$graph->legend->Pos(0.4,0.95,"center","bottom");
52
53// Display the graph
54$graph->Stroke();
55?>
Note: See TracBrowser for help on using the repository browser.