QCustomPlot Discussion and Comments

A broken line style diagram is only partly visibleReturn to overview


In the setupSincScatterDemo I calculate a residual and want to draw it in a window using the style of demo(1). I.e. I expect a broken blue line filled below the line. The filled area (produced by the brush) is OK, but the broken line is not drawn when the slope is too high, i.e. broken line is visible only over the sections where the slope is low. To reproduce the problem: I use the data generated by setupSincScatterDemo, and I added the residual calculation as

for (int i=0; i<50; ++i)
  {
     ...
      YResidual[i] = (Y1[i]-Y0[i])/sqrt(Y1[i]);
  }

and draw it as

void ESsistMe_ResidualWindow::setupSimpleDemo(QCustomPlot *customPlot)
{
  customPlot->setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));
  customPlot->addGraph();
  customPlot->graph(0)->setPen(QPen(Qt::blue));
  customPlot->graph(0)->setBrush(QBrush(QColor(0, 0, 255, 20))); 
  customPlot->graph(0)->setData(X1,  YResidual);
  customPlot->graph(0)->rescaleAxes();
}

In the sincScatterDemo, y0 has 251 points and y1 has 51 points for the same length, so subtracting the values of those vectors at the same indices doesn't make sense. How do you create your Y0 and Y1 from those?

You should also use the absolute value of Y1 before taking its square root (since sincScatterDemo's y1 contains negative values), in case you're not already doing that in your generation of Y1. Because this otherwise gives you NaNs in your values and QCustomPlot intentionally leaves gaps in this case (see QCPGraph docs).

//EDIT: Another thing: In statistics, residuals usually aren't divided by the square root of the data point. Don't know what you're calculating there, but it's not the residual.