jpGraph绘制具有负值的行,将刻度设置为0

时间:2017-05-21 13:13:19

标签: jpgraph

我使用jpGraph在折线图上绘制项目。值从-20扩展到+20,但是当我输出图形时,X轴标签从0开始,因此它们位于图形的中间,而不是在底部:

Sample graph with tick labels in the middle

以下是复制问题的代码:

<?php
    // Using the Composer version: https://packagist.org/packages/jpgraph/jpgraph
    require("vendor/autoload.php");

    \JpGraph\JpGraph::load();
    \JpGraph\JpGraph::module('line');

    $graph = new \Graph(640, 480);
    $graph->SetScale("textint", -20, 20);

    $magValues = [-20, -10, 0, 10, 20];

    $lplotMag = new LinePlot($magValues);
    $graph->Add($lplotMag);

    $graph->Stroke();

?>

如何强制X轴标签位于图形的底部?

1 个答案:

答案 0 :(得分:0)

您需要添加此属性

$ graph-&GT; xaxis-&GT; SetPos( “MIN”);