Results 1 to 2 of 2

Thread: setScaleAxis(), setScaleDiv() problem..

  1. #1
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default setScaleAxis(), setScaleDiv() problem..

    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));

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setScaleAxis(), setScaleDiv() problem..

    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

Similar Threads

  1. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.