Results 1 to 3 of 3

Thread: spectrogram example problem

  1. #1
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default spectrogram example problem

    I modified the spectrogram example to plot a 10x10 unit image with the original 3x3 unit image inside it. I changed the axis values to be -5 to +5 for both the x & y axis and the constructor rectangle values to (-5, -5, 10, 10). I then enabled the top axis and disabled the bottom axis. The plot is clipped at about -4 to +4 on the x axis only when the axis is at the top. If it is at the bottom, it is plotted OK. Any way to fix this? Am I doing something wrong?

    Here is the code:

    Qt Code:
    1. class SpectrogramData: public QwtRasterData
    2. {
    3. public:
    4. SpectrogramData():
    5. // QwtRasterData(QwtDoubleRect(-1.5, -1.5, 3.0, 3.0))
    6. QwtRasterData(QwtDoubleRect(-5.0, -5.0, 10.0, 10.0))
    7. {
    8. }
    9.  
    10. virtual QwtRasterData *copy() const
    11. {
    12. return new SpectrogramData();
    13. }
    14.  
    15. virtual QwtDoubleInterval range() const
    16. {
    17. return QwtDoubleInterval(0.0, 10.0);
    18. }
    19.  
    20. virtual double value(double x, double y) const
    21. {
    22. const double c = 0.842;
    23.  
    24. const double v1 = x * x + (y-c) * (y+c);
    25. const double v2 = x * (y+c) + x * (y+c);
    26.  
    27. if ((x < -1.5 || x > 1.5) || (y < -1.5 || y > 1.5))
    28. return 0.0; // return 0 outside 3 unit box
    29.  
    30. return 1.0 / (v1 * v1 + v2 * v2);
    31. }
    32. };
    33.  
    34. Plot::Plot(QWidget *parent):
    35. QwtPlot(parent)
    36. {
    37. d_spectrogram = new QwtPlotSpectrogram();
    38.  
    39. #ifndef DO_TOP
    40. enableAxis(xTop, true);
    41. enableAxis(xBottom, false);
    42. setAxisScale(QwtPlot::xTop, -5.0, 5.0);
    43. #else
    44. setAxisScale(QwtPlot::xBottom, -5.0, 5.0);
    45. #endif
    46. setAxisScale(QwtPlot::yLeft, -5.0, 5.0);
    47.  
    48. QwtLinearColorMap colorMap(Qt::darkCyan, Qt::red);
    49. colorMap.addColorStop(0.1, Qt::cyan);
    50. colorMap.addColorStop(0.6, Qt::green);
    51. colorMap.addColorStop(0.95, Qt::yellow);
    52.  
    53. d_spectrogram->setColorMap(colorMap);
    54.  
    55. d_spectrogram->setData(SpectrogramData());
    56. d_spectrogram->attach(this);
    57.  
    58. ..... the rest of the code is the same......
    To copy to clipboard, switch view to plain text mode 

    I also have included two jpeg files that show the normal bottom axis result and the invalid top axis result.

    Thanks in advance for any help.

    Jim
    Attached Images Attached Images

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

    Default Re: spectrogram example problem

    Assuming you want the spectrogram displayed according to the top axis:

    Qt Code:
    1. d_spectrogram->setAxis(QwtPlot::xTop, QwtPlot::yLeft);
    To copy to clipboard, switch view to plain text mode 

    Uwe

  3. #3
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: spectrogram example problem

    Thank You! That made it work like I wanted.

    Jim

Similar Threads

  1. Incremental Spectrogram...
    By uppu in forum Qwt
    Replies: 11
    Last Post: 13th April 2011, 14:47
  2. Resolution Spectrogram
    By edney in forum Qwt
    Replies: 3
    Last Post: 13th April 2010, 08:44
  3. get min and max value from spectrogram
    By rambo83 in forum Qwt
    Replies: 1
    Last Post: 2nd December 2009, 15:25
  4. scrolling spectrogram
    By mcarter in forum Qwt
    Replies: 2
    Last Post: 30th November 2009, 15:22
  5. qwt spectrogram example
    By rambo83 in forum Qwt
    Replies: 2
    Last Post: 17th November 2009, 22:13

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.