PDA

View Full Version : setScaleAxis(), setScaleDiv() problem..



halberdier83
3rd April 2008, 14:48
Hi all,

curve : QwtPlotCurve
qwtPlot : QwtPlot
double* x_data;
double* y_data;
int dataLen = 1000;

I have a problem on setting x-axis scale.

* I am plotting data by using curve->setRawData(x_data, y_data, dataLen) where
y_data = new double[dataLen]; // y_data is filled due to the plot data
x_data = new double[dataLen];
for(int i=0; i dataLen; i++)
x_data[i] = (double)i;

* But i want my plot to be seen in the interval [-500, 500]. So i add the line
qwtPlot->setAxisScale(QwtPlot::xBottom, -(dataLen/2)+1, dataLen/2);

After plotting via curve->setRawData(x_data, y_data, dataLen) code: it is seen in the plot as zeros [-500,0] and half of the plot values between [0,500]. Then, i got a segmentation fault.

What can the problem be?

Shortly, i want to plot data and set the axis scales independent of the plot data. y data may be between [0, 1000], but i want to show the plot between [-500, 500].

Note : I tried following code, but nothing happened.
QwtScaleEngine* xScale = qwtPlot->axisScaleEngine(QwtPlot::xBottom);
qwtPlot->setAxisScaleDiv(QwtPlot::xBottom, xScale->divideScale(-(dataLen/2)+1, dataLen/2, 10, 5));

Uwe
4th April 2008, 08:02
Then, i got a segmentation fault. What can the problem be?
The posted code snippet seems to be ok. Start your debugger and look at the stack.


Note : I tried following code, but nothing happened.
QwtScaleEngine* xScale = qwtPlot->axisScaleEngine(QwtPlot::xBottom);
qwtPlot->setAxisScaleDiv(QwtPlot::xBottom, xScale->divideScale(-(dataLen/2)+1, dataLen/2, 10, 5));
This is what you want to do: qwtPlot->setAxisScale(QwtPlot::xBottom, -500.0, 500.0);

Uwe