我也有同样的问题。如果您检查类参考中的 LinePlot,您会看到您可以为 x 轴值设置第二个参数。显然,Y 轴和 X 轴数组必须具有相同数量的元素。我根据手册做了一些示例代码。该代码尚未经过测试,但它应该是这样工作的:
function elevation_chart ($ydata, $xdata) {
require_once('jpgraph/jpgraph.php');
require_once('jpgraph/jpgraph_line.php');
$width = 600; $height = 200;
$graph = new Graph($width,$height);
$graph->SetScale('intint');
$graph->title->Set('Elevation profile');
$graph->xaxis->title->Set('(Distance)');
$graph->yaxis->title->Set('(Altitude)');
$lineplot = new LinePlot($ydata, $xdata); //here you have to add $xdata as second argument
$graph->Add($lineplot);
$graph->Stroke();
}