Dankevich
Dankevich

Reputation: 304

How to draw a smooth curve?

I have a set of points to plot and their coordinates are stored in

QVector<double> x(200), y(200);

I'd like to connect them with some smooth curve, any, say, splines. Or a bigger array of points between knots would also suffice. My try is

customPlot->addGraph();
customPlot->graph(0)->setData(x, y);
customPlot->graph(0)->setPen(QPen(Qt::blue));
customPlot->xAxis->setLabel("Index");
customPlot->yAxis->setLabel("Amplitude");
customPlot->xAxis->setRange(0, 200);
customPlot->yAxis->setRange(-3, 3);

I tried using:

Upvotes: -1

Views: 1963

Answers (1)

Lifeisabug
Lifeisabug

Reputation: 386

From the code I would say you are using Qt Charts.

There is a QSplineSeries you can use that does exactly what you want.

Upvotes: 2

Related Questions