我想用 qcustomplot 在离散点绘制两个函数之间的残差。
我知道位置 (x)、起始值 y.at(x) 和 height.at(x)。
到目前为止,我有一个带有 y+-error 的错误栏:
QCPErrorBars *errorBars = new QCPErrorBars(customPlot->xAxis, customPlot->yAxis);
errorBars->setDataPlottable(customPlot->graph(0));
QVector<double> y1err(x.size());
for (int i = 0; i<x.size(); ++i)
{
y1err[i] = y.at(i) * error;
}
customPlot->graph(0)->setData(QVector<double>::fromStdVector(x), QVector<double>::fromStdVector(y));
errorBars->setData(y1err);
或从零开始的条形图:
QCPBars *newBars = new QCPBars(customPlot->xAxis, customPlot->yAxis);
std::vector<double> xData, yData;
for (auto i = 0; i < x.size(); ++i)
{
xData.push_back(i+1);
yData.push_back(y.at(i));
}
newBars->setData(QVector<double>::fromStdVector(x), QVector<double>::fromStdVector(y));
但我真正想要的是某种从 y.at(x) 值开始的图,除了两个 xy 图之外,还有点 x 处的残差高度。如何使用 height.at(x) 从 y.at(x) 开始绘制条形图或误差线?
谢谢