Results 1 to 6 of 6

Thread: qwt 6.0.0 logaritmic scaling disturbes data

  1. #1
    Join Date
    Feb 2013
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Android

    Default qwt 6.0.0 logaritmic scaling disturbes data

    First of all hello, i'm new in here

    I use qwt 6.0.0 with qt 4.8.1 within linux (ubuntu 12.04).

    I use qwt to draw real time audio signals and the corresponding power spectrum (calculated with fftw). The audio buffer is about 150ms with 44kHz sample rate. The drawing gets updated in a 100ms interval. The drawing of the power spectrum uses a user selectable logarithmic or an linear scale for both x,y-axis (see application code for y):

    Qt Code:
    1. if( scaleLog == true ){
    2. ui->qwtFreqPlot->setAxisScaleEngine(QwtPlot::yLeft, se);
    3. }
    4. else{
    5. ui->qwtFreqPlot->setAxisScaleEngine(QwtPlot::yLeft, se);
    6. }
    To copy to clipboard, switch view to plain text mode 

    Now my problem:

    Qwt seams to plot random points at lower frequencies which do not exist. It only does this if logarithmic scaling of y axis is choosen, the x axis scaling seams to have no effect on this. I already analysed the data using gnuplot, to know if there is any corruption but the data is not disturbed as you can see in the attached screenshots. I alreday recognized this quit a while ago but because it is only a display bug i did not pay much attention to it. In fact i wanted to know if any one here recognized something similar. I recognized this already in earlier versions of qwt (5.x). Maybe some one could give me a hint, thanx a lot...

    qwtlogscalebug.jpg
    qwtlogscalebuggnuplot.png

    cheerz x

    p.s. it's just a hobby software development in my freetime so it's not urgently but i want to fix this because it simply does not look good.

  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: qwt 6.0.0 logaritmic scaling disturbes data

    I don't see how an effect like on the second screen shot might be related to how curve points are mapped to a polygon . So I'm pretty sure, that the reason is a bug in application code.

    The reason for the bad lines in your plot might be from:


    1. another curve
    2. bad samples at the beginning/end of your curve.


    The relevant code can be found in QwtPlotCurve::drawLines(). Adding some debug statements here you should be able to find out what is going wrong easily.

    Uwe

  3. #3
    Join Date
    Feb 2013
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Android

    Default Re: qwt 6.0.0 logaritmic scaling disturbes data

    The reason for the bad lines in your plot might be from:

    1. another curve
    2. bad samples at the beginning/end of your curve.
    Thank you for your quick response, i'll give that a try on thursday...

    By the way: When i use drawDots() instead of drawLines() the problem disapears - all dots are drawn correct, no artefacts appear

    Clearly it could/must be a problem related to my application code that was the first thing i checked before posting here (maybe not intense enough). I'm sorry, for now i'm at work i don't have the code and time to test it here or later today. So i'll answer on thursday evening after i spend some more time on the problem... My hope for to post here was that someone may have had some kind of similar problems using log scale. I'll try to reproduce this in example code,

    x

  4. #4
    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: qwt 6.0.0 logaritmic scaling disturbes data

    Quote Originally Posted by xam View Post
    By the way: When i use drawDots() instead of drawLines() the problem disapears - all dots are drawn correct, no artefacts appear
    Because the bad points are above and below the visible area. In dots style those are simply clipped away, in lines style you see the connections.

    Uwe

  5. #5
    Join Date
    Feb 2013
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Android

    Default Re: qwt 6.0.0 logaritmic scaling disturbes data

    Because the bad points are above and below the visible area. In dots style those are simply clipped away, in lines style you see the connections.
    This sounds comprehensible, i gonna check this later this evening when i'm home in front of the code...

    Some questions which came up this morning. Looking into the docs not clearly satisfied them:

    1) How to make sure that QwtPlot contains only one curve? How check attached curves count?
    2) Are there any methods to clear (detach) the curves of a plot in an efficient way?
    3) What would be the best way to fully clear a curve before calling setRawSamples(..) in an updating routine?

    Actually i call it within an iterative update routine like this (pseudo code):

    Qt Code:
    1. ...
    2. curve->setRawSamples(...);
    3. curve->attach(myPlot);
    4. myPlot->replot();
    5. ...
    To copy to clipboard, switch view to plain text mode 

    thanks

  6. #6
    Join Date
    Feb 2013
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Android

    Default Re: qwt 6.0.0 logaritmic scaling disturbes data

    Hi, i found the problem...

    I'm sorry for posting it here, because it was clearly a failure/bug in my application. To point it out in detail:

    It happend because of the nature of fft and the nyquist theorem. In frequence domain only half of the array is initialized by the fftw. The fftw-doc and some dusty knowledge of mine from high school gave me the hint: After looking at the data points again i realized that the disturbed points came from the last half of the array. This part of the data had informations which are rubbish due to the frequency plotting. So just plotting the relevant data did the "trick"

    In fact gnu plot handles this "rubbish" different than qwt. So thanks to Uwe, you where totally right...

    bad samples at the beginning/end of your curve.
    ...caused the disturbed representation of the frequence spectrum.


    Added after 14 minutes:


    If you like to reproduce/plot the "disturbed" data using qwt, see attached file fft.zip
    It just contains the x,y coordinates...
    Last edited by xam; 1st March 2013 at 01:12.

Similar Threads

  1. QwtPlotMarker and scaling
    By carhun in forum Qwt
    Replies: 14
    Last Post: 10th July 2012, 13:30
  2. DPI Scaling issue
    By eric_vi in forum Qt Programming
    Replies: 0
    Last Post: 9th October 2010, 15:24
  3. Scaling Issue
    By cnbp173 in forum Qwt
    Replies: 1
    Last Post: 19th February 2009, 07:13
  4. Scaling
    By AD in forum Qt Programming
    Replies: 16
    Last Post: 11th July 2008, 10:55
  5. Scaling Painter without scaling the coordinate sytem
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2008, 21:30

Tags for this Thread

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.