Results 1 to 3 of 3

Thread: Problem with scatter plot, refreshing, animating and zooming.

  1. #1
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem with scatter plot, refreshing, animating and zooming.

    Hello,

    My purpose is to show a graphical representation of a RAW data from a 3-axis accelerometer. For this, I read the RAW data file and get the information into a typedef structure. This raw data is downsampled to 1 sample per second for handle it in a fast way.

    The goal is to show a period of time requiered from a main window, and animate this plot with a vertical bar, for play like in real time, in order to follow the data showed.

    For this I need to plot a specific period of time and label it as well.

    I could do it, but I found several problems. I really would appreciate if somebody can help me, even with just one of them....

    1. Y-Axis. When I plot, the scale in the y-axis is not correct, it doesn't appear anything until i move the mouse wheel (zoom). With just moving the zoom, it is looking correct in the y-axis.

    inicial.jpeg


    2. X-Axis. I have to plot information of a period of time (ex, from 1pm to 2pm). After plotting, it is not exactly correct. It shows like from 1:05 to 1:55, and I need to zoom out one time for the correct adjustment.

    acc1.jpeg

    acc1_correcto.jpeg

    3. After closing one window with the plot, and trying to plot a different period of time, in the legend, appears the new and the old functions for plotting... and they don't work well, I mean, if I tick one of them, disappears part of the function, not all of it.

    legend_problem.jpeg

    4. When I can solve the problems above, I would like to animate it with a vertical bar, any suggestion about it?

    Thanks in advance!

  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: Problem with scatter plot, refreshing, animating and zooming.

    1. Y-Axis. When I plot, the scale in the y-axis is not correct, ...
    What do you mean by plot - and how do you set your y-axis ?

    2. X-Axis. I have to plot information of a period of time (ex, from 1pm to 2pm). After plotting, it is not exactly correct. It shows like from 1:05 to 1:55, and I need to zoom out one time for the correct adjustment.
    As you don't seem to have an idea how you get your scales I guess you are using autoscaling. Use QwtPlot::setAxisScale or even QwtPlot::setAxisScaleDiv() instead.

    3. After closing one window with the plot, and trying to plot a different period of time, in the legend, appears the new and the old functions for plotting... and they don't work well, I mean, if I tick one of them, disappears part of the function, not all of it..
    A bug in your code - you didn't remove the previous curves before you insert the new ones.

    4. When I can solve the problems above, I would like to animate it with a vertical bar, any suggestion about it?
    Be careful with such a feature:

    It is possible to paint incrementally ( QwtPlotDirectPainter ), but it is not possible to erase something without having to replot. So when you have many points and you want to update with high frame rates such a bar might be a performance issue, when you don't understand how rendering works in detail.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    breotone (7th October 2011)

  4. #3
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with scatter plot, refreshing, animating and zooming.

    Hi Uwe, thanks a lot for your reply!

    1. This is my code for the y-axis scale. It is fitting this range in the window after a movement of zoom out.

    setAxisScale( QwtPlot::yLeft, -8.5, 8.5 );
    setAxisTitle( QwtPlot::yLeft, "g-force" );


    2. This is the code for the x-Axis.

    QList<double> ticks[QwtScaleDiv::NTickTypes];
    ticks[QwtScaleDiv::MajorTick] << 0 << numberOfSamples;

    QwtScaleDiv scaleDiv(
    ticks[QwtScaleDiv::MajorTick].first(),
    ticks[QwtScaleDiv::MajorTick].last(),
    ticks );

    setAxisScaleDiv(QwtPlot::xBottom, scaleDiv);
    setAxisTitle( QwtPlot::xBottom, " System Uptime [h:m:s]" );

    //Axis for drawing with the date with format
    setAxisScaleDraw( QwtPlot::xBottom, new TimeScaleDraw( this->drawSettings.firstMinute ) );
    setAxisLabelRotation( QwtPlot::xBottom, -50.0 );
    setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom );

    3. And for the legend:

    //Clikable LEGEND
    QwtLegend *legend = new QwtLegend;
    legend->setItemMode( QwtLegend::CheckableItem );
    this->insertLegend( legend, QwtPlot::RightLegend );


    The main problem can be the architecture I am using. I have an object, with 2 main methods, collecting_data and drawing.

    The firs thing to do in my program is collecting the data, and after this, I have a button in a main window for drawing a specific period of time, so maybe when I press close, I should destroy the object, but I can not because the information is in this object... so I have to find a way to refresh the plot with the values I want..

    Thanks!

Similar Threads

  1. how to plot scatter graph?
    By rambo83 in forum Qwt
    Replies: 0
    Last Post: 25th February 2010, 12:24
  2. Scatter plot with custom symbols
    By jcox23 in forum Qwt
    Replies: 4
    Last Post: 5th February 2010, 12:54
  3. Labeling scatter plot points
    By hamid ghous in forum Qwt
    Replies: 1
    Last Post: 29th October 2009, 06:35
  4. Scatter plot with many colors
    By DKL1972 in forum Qwt
    Replies: 4
    Last Post: 29th June 2008, 11:15

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.