您好,欢迎访问一九零五行业门户网

php使用Jpgraph绘制坐标图高级篇

本文主要介绍了php使用jpgraph绘制复杂x-y坐标图的方法,通过设置图像阴影、边距、字体、颜色、曲线等实现jpgraph绘制复杂坐标图的功能。希望对大家有所帮助。
具体实现方法如下:
<?php include ("src/jpgraph.php"); include ("src/jpgraph_line.php"); $data1 = array(19,23,34,38,45,67,71,78,85,87,90,96); //第一条曲线的数组 $data2 = array(523,634,371,278,685,587,490,256,398,545,367,577); //第二条曲线的数组 $graph = new graph(400,300); //创建新的graph对象 $graph->setscale("textlin"); $graph->sety2scale("lin"); $graph->setshadow(); //设置图像的阴影样式 $graph->img->setmargin(40,50,20,70); //设置图像边距 $graph->title->set("年度收支表"); //设置图像标题 $lineplot1=new lineplot($data1); //创建设置两条曲线对象 $lineplot2=new lineplot($data2); $graph->add($lineplot1); //将曲线放置到图像上 $graph->addy2($lineplot2); $graph->xaxis->title->set("月份"); //设置坐标轴名称 $graph->yaxis->title->set("兆美元"); $graph->y2axis->title->set("兆美元"); $graph->title->setfont(ff_simsun,fs_bold); //设置字体 $graph->yaxis->title->setfont(ff_simsun,fs_bold); $graph->y2axis->title->setfont(ff_simsun,fs_bold); $graph->xaxis->title->setfont(ff_simsun,fs_bold); $lineplot1->setcolor("red"); //设置颜色 $lineplot2->setcolor("blue"); $lineplot1->setlegend("cost amount"); //设置图例名称 $lineplot2->setlegend("revenue amount"); $graph->legend->setlayout(legend_hor); //设置图例样式和位置 $graph->legend->pos(0.4,0.95,"center","bottom"); $graph->stroke(); //输出图像 ?>
运行效果如下图所示:
相关推荐:
php使用jpgraph绘制坐标图基础篇
php图形操作之jpgraph
php报表之jpgraph柱状图实例代码
以上就是php使用jpgraph绘制坐标图高级篇的详细内容。
其它类似信息

推荐信息