qwtplot drawing lines with negative values
Good day to you!
I'm trying to draw lines on my QwtPlot graph, and using this construction:
Code:
ui_plot->setAutoFillBackground(true);
ui_plot
->setCanvasBackground
(QColor(0xE3E3E3
));
ui_plot
->setAxisScale
(QwtPlot::yLeft,
-1,
1);
ui_plot
->setAxisScale
(QwtPlot::xBottom,
-1,
1);
ui_plot
->enableAxis
(QwtPlot::yLeft,
true);
ui_plot
->enableAxis
(QwtPlot::xBottom,
true);
double x[3] ={-1.0, 0.0, 1.0};
double y[3] ={0,0,0};
xline->attach(ui_plot);
ui_plot->replot();
I expect to have line, drawn from -1 to 1. But for some reason i always receive line from 0 to +∞. It's weird and i really want to know, what kind of data i should use to draw a simple x[-1;0;1] y[0;0;0] line. Can you help me please?
Re: qwtplot drawing lines with negative values
Guess x/y are on the stack and get overwritten by some random data.
Uwe
Re: qwtplot drawing lines with negative values
I solved it this way:
Code:
double x1[3] = {-1.5, 0, 1.5};
double y1[3] = {0, 0, 0};
double x2[3] = {0, 0, 0};
double y2[3] = {-1.5, 0, 1.5};
x_1_line->setSamples(x1,y1,3);
y_1_line->setSamples(x2,y2,3);
x_1_line
->setPen
(QPen(QColor(Qt
::black),
1,Qt
::DashLine));
y_1_line
->setPen
(QPen(QColor(Qt
::black),
1,Qt
::DashLine));
x_1_line->attach(ui_plot);
y_1_line->attach(ui_plot);
ui_plot->replot();