[JpGraph]⑤--繪制XYY坐標(biāo)圖

<?php
//引入類庫(kù)
require_once "../src/jpgraph.php";
require_once "../src/jpgraph_line.php";
$data = array(0 => -21, 1 => -3, 2 => 12, 3 => 19, 4 => 23, 5 => 29, 6 => 30, 7 => 22, 8 => 26, 9 => 18, 10 => 5, 11 => -10);//第一條數(shù)據(jù)
$data2y = array(0 => 3, 1 => 12, 2 => 18, 3 => 30, 4 => 28, 5 => 33, 6 => 43, 7 => 39, 8 => 36, 9 => 29, 10 => 15, 11 => 10);//第二條數(shù)據(jù)
//得到Graph對(duì)象
$graph = new Graph(400, 400);
//設(shè)置X和Y軸樣式及Y軸的最大值最小值
$graph->SetScale("textint", -30, 50);
//設(shè)置右側(cè)Y軸樣式及其最大值最小值
$graph->SetY2Scale("int", -30, 50);
//設(shè)置圖像樣式,加入陰影
$graph->SetShadow();
//設(shè)置圖像邊界范圍
$graph->img->setMargin(40, 30, 50, 70);
//設(shè)置標(biāo)題
$graph->title->Set("this is a test X-Y-Y");
//得到曲線實(shí)例
$linePlot = new LinePlot($data);
//得到第二條曲線
$linePlot2y = new LinePlot($data2y);
//將曲線加入到圖像中
$graph->Add($linePlot);
$graph->Add($linePlot2y);
//設(shè)置三個(gè)坐標(biāo)軸名稱
$graph->xaxis->title->Set("Month");
$graph->yaxis->title->Set("beijing");
$graph->y2axis->title->Set("ShangHai");
//設(shè)置兩條曲線的顏色
$linePlot->SetColor("red");
$linePlot2y->SetColor("black");
//設(shè)置兩條曲線的圖例
$linePlot->SetLegend("Beijing");
$linePlot2y->SetLegend("Shanghai");
//設(shè)置圖例樣式
$graph->legend->setlayout(LEGEND_HOR);
$graph->legend->Pos(0.45, 0.9, "center", "bottom");
//將圖像輸出到瀏覽器
$graph->Stroke();
Paste_Image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容