QCustomPlot Discussion and Comments

wrong point's orderReturn to overview

Hello.

customPlot = new QCustomPlot();
    customPlot->addGraph(customPlot->xAxis, customPlot->yAxis);
    customPlot->graph(0)->setPen(QPen(Qt::blue)); // line color blue for first graph
    QVector<double> x1, y1;

    x1.append(0);
    y1.append(0);

    x1.append(0);
    y1.append(1);

    x1.append(3);
    y1.append(1);

    x1.append(4);
    y1.append(2);

    customPlot->graph(0)->setData(x1, y1);
    customPlot->graph(0)->rescaleAxes(true);

Line chart is drawn from (0, 1) to (0,0) and then (3,1) and (4,2)
instead (0,0) to (0,1).

And vise versa:

QVector<double> x1, y1;

    x1.append(0);
    y1.append(1);

    x1.append(0);
    y1.append(0);
...

Line chart is drawn from (0, 0) to (0,1) and then (3,1) and (4,2)
instead (0,1) to (0,0).

Use one of the step line modes if you want to draw steps. Or if you want to still have multiple data points with the same key (which QCPGraph isn't meant for), use QCPCurve.

Thanks a lot.
QCPCurve works great.