QCustomPlot 填充连接线
QCustomPlot fills in lines that connect
使用 QT 的 QCustomPlot 插件。我不得不绘制可能非线性的点,因此图形可能看起来像这样
这是怎么回事
但这就是显示的结果
使用此代码
plotter->addGraph();
plotter->graph(0)->setData(xVector, yVector);
plotter->xAxis->setLabel("X");
plotter->yAxis->setLabel("Y");
plotter->xAxis->setRange(x_data_range_min x_data_range_max);
plotter->yAxis->setRange(y_data_range_min, y_data_range_max);
plotter->replot();
plotter->saveJpg("test.jpg");
plotter->close();
现在我找到了一个部分修复方法,通过添加此选项来获取连接线并仅显示点,
plotter->graph(0)->setLineStyle((QCPGraph::LineStyle)QCPGraph::lsNone);
plotter->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc , 3));
结果是这样的,但有一个问题,它留下了一个我不能拥有的有点大胆的地方
所以这是一个半解决方案。所以我继续添加 A. Sarid 在下面的回复中提到的内容。我认为第一张图可能绘制得很好,但之后的任何其他图看起来都像这样
所以我不确定哪种解决方案只能使点按照从数组接收到的顺序连接
几天前我遇到了同样的问题。
您需要使用 QCPCurve Class 而不是 Graph。这是一个如何操作的小例子:
this->newCurve = new QCPCurve(ui->customPlot->xAxis, ui->customPlot->yAxis);
ui->customPlot->addPlottable(this->newCurve);
然后您可以像使用图形一样使用它,例如:
this->newCurve->setData(x, y);
使用 QT 的 QCustomPlot 插件。我不得不绘制可能非线性的点,因此图形可能看起来像这样
这是怎么回事
但这就是显示的结果
使用此代码
plotter->addGraph();
plotter->graph(0)->setData(xVector, yVector);
plotter->xAxis->setLabel("X");
plotter->yAxis->setLabel("Y");
plotter->xAxis->setRange(x_data_range_min x_data_range_max);
plotter->yAxis->setRange(y_data_range_min, y_data_range_max);
plotter->replot();
plotter->saveJpg("test.jpg");
plotter->close();
现在我找到了一个部分修复方法,通过添加此选项来获取连接线并仅显示点,
plotter->graph(0)->setLineStyle((QCPGraph::LineStyle)QCPGraph::lsNone);
plotter->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc , 3));
结果是这样的,但有一个问题,它留下了一个我不能拥有的有点大胆的地方
所以这是一个半解决方案。所以我继续添加 A. Sarid 在下面的回复中提到的内容。我认为第一张图可能绘制得很好,但之后的任何其他图看起来都像这样
所以我不确定哪种解决方案只能使点按照从数组接收到的顺序连接
几天前我遇到了同样的问题。 您需要使用 QCPCurve Class 而不是 Graph。这是一个如何操作的小例子:
this->newCurve = new QCPCurve(ui->customPlot->xAxis, ui->customPlot->yAxis);
ui->customPlot->addPlottable(this->newCurve);
然后您可以像使用图形一样使用它,例如:
this->newCurve->setData(x, y);