2016-11-14 14 views
0

qcustomplot을 사용하여 불연속 점에있는 두 함수 사이에 잔차를 그립니다.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)부터 시작하는 막대 또는 오류 막대를 플로팅 할 수 있습니까?

고맙습니다.

답변

0

이 문제에 직면 한 다른 사람들을 위해 나는 해결책을 찾았습니다.

void QLinePlot::AddResiduumData(std::vector<double> x, std::vector<double> y_mid, std::vector<double> y_res) 
{ 
customPlot->addGraph(); 
++graphCountI; 

QCPErrorBars *errorBars = new QCPErrorBars(customPlot->xAxis, customPlot->yAxis); 
errorBars->setDataPlottable(customPlot->graph(graphCountI - 1)); 
customPlot->graph(graphCountI - 1)->setData(QVector<double>::fromStdVector(x), QVector<double>::fromStdVector(y_mid)); 
customPlot->graph(graphCountI - 1)->setVisible(false); 
errorBars->setData(QVector<double>::fromStdVector(y_res)); 
customPlot->replot(); 
} 

이 뒤에 아이디어는 두 플롯 사이에 새로운 보이지 않는 그래프를 추가하고 둘 사이의 거리의 절반으로 오류를 제공한다.