QCustomPlot Discussion and Comments

How to display the max value of the xaxis?Return to overview

Hi all, I just plot a line as the following:

int N = 1024;
 QVector<double> x(N), y(N);
  for (int i=0; i<(N); ++i)
      x[i] = i;
      y[i] = i;
  customPlot->graph(0)->setData(x, y);

I found, the xaxis ticker shows "0 200 400 600 800 1000", but I want to show the max value as "0 xxx xxx 1024", how should I do?

I just have 1024 points, the max xaxis value is 1023, but I want the rightmost xaxis show "1024".

You just have to add the lines:

customPlot->xAxis->setRange(0, 1024);
customPlot->yAxis->setRange(0, 1024);

Instead of using customPlot->graph(0)->rescaleAxes();.

I just have tried customPlot->xAxis->setRange(0, 1024); It did works, Thanks!
But when I change 1024 to 1280, the max value of the xaxis displayed was 1250 NOT 1280,
How should I do to make it display 1280?

Have you tried this: customPlot->xAxis->setRange(0, 1280); ?
If it hasn't worked, you should use customPlot->replot(); just after that.