Hi all,
I have this code to plot the x^2 curve:
// add curves
//set curve color
curve1
->setPen
(QPen(Qt
::red,
2));
// add curves
curve1->attach(ui->qwtPlotWidget);
const int MAX_VALUES = 100;
double x[2*MAX_VALUES], y1[2*MAX_VALUES];// x and y values
for (int i (-MAX_VALUES); i < MAX_VALUES; i++)
{
x[i] = i;
y1[i] = i*i;
}
// copy the data into the curves
curve1->setSamples(x, y1, 2*MAX_VALUES);
// finally, refresh the plot
ui->qwtPlotWidget->replot();
// add curves
QwtPlotCurve *curve1 = new QwtPlotCurve("Graph 1");
//set curve color
curve1->setPen(QPen(Qt::red, 2));
// add curves
curve1->attach(ui->qwtPlotWidget);
const int MAX_VALUES = 100;
double x[2*MAX_VALUES], y1[2*MAX_VALUES];// x and y values
for (int i (-MAX_VALUES); i < MAX_VALUES; i++)
{
x[i] = i;
y1[i] = i*i;
}
// copy the data into the curves
curve1->setSamples(x, y1, 2*MAX_VALUES);
// finally, refresh the plot
ui->qwtPlotWidget->replot();
To copy to clipboard, switch view to plain text mode
But I get this strange plot:
What's wrong?
Regards.
Bookmarks