Results 1 to 7 of 7

Thread: QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

  1. #1
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

    I have a plot working now with QwtPlotSpectrogram using my own data class for continuous interpolated values.

    The documentation on QwtPlotSpectrogram is fairly brief, so I've been following the example/Spectrogram. I decided to try turning on contour lines and added initialization of the contour levels using setContourLevels with code similar to this...

    Qt Code:
    1. QList<double> contourLevels;
    2. for ( double level = 0.5; level < 110.0; level += 15.0 )
    3. contourLevels += level;
    4. spectrogram->setContourLevels( contourLevels );
    5.  
    6. spectrogram->setDefaultContourPen( QPen() );
    7. spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, true);
    To copy to clipboard, switch view to plain text mode 

    This follows the example code pretty closely. I use a QwtPlotGrid as well.

    I don't see the lines drawn over my spectrogram plot, so I tried disabling ImageMode and only enabling the ContourMode, but this produced nothing.

    I'm sure I'm missing something simple. I'm not subclassing QwtPlotSpectrogram- only the data class. Everything is working with the ImageMode and my spectrogram plot, except the countour lines.

    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: QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

    Hard to say something useful without knowing your application: maybe the levels don't match the valid range of your z-values ?

    Uwe

  3. #3
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

    The z values are histogram bins with the maximum bin contents being ~106 in the data set I'm plotting. The colorbar is enabled and the axis scale set on the right via:

    Qt Code:
    1. plot->setAxisScale(QwtPlot::yRight, 0.0, (double) largestBin);
    To copy to clipboard, switch view to plain text mode 

    The color bar shows correctly with the correct scale, the plot is rendering with the right colors. I'm currently doing bilinear interpolation on the data return from value() since the data is stored in discrete bins.

    The left/Y axis is set to autoscale. The X axis is setup with the QwtLog10ScaleEngine and scaled manually. The setup code looks like this:

    Qt Code:
    1. QDialog dlg;
    2. QVBoxLayout *layout = new QVBoxLayout(&dlg);
    3. QwtPlot *plot = new QwtPlot();
    4.  
    5. QwtPlotGrid *grid = new QwtPlotGrid();
    6. grid->enableXMin(true);
    7. grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
    8. grid->setMinPen(QPen(Qt::lightGray, 0 , Qt::DotLine));
    9. grid->attach(plot);
    10. grid->setZ(5);
    11.  
    12. QwtPlotSpectrogram *spectrogram = new QwtPlotSpectrogram();
    13. spectrogram->setRenderThreadCount( 0 );
    14.  
    15. spectrogram->setColorMap( new ColorMap() );
    16.  
    17. spectrogram->setYAxis(QwtPlot::yLeft);
    18. spectrogram->setRenderHint(QwtPlotItem::RenderAntialiased);
    19.  
    20. plot->setAxisMaxMajor(QwtPlot::xBottom, 8);
    21. plot->setAxisMaxMinor(QwtPlot::xBottom, 10);
    22. plot->setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine());
    23. plot->setAxisScale(QwtPlot::xBottom, 1e-16, 1e-8);
    24. plot->setAxisAutoScale( QwtPlot::yLeft );
    25.  
    26. // Y bins... (X bins handled by histogram class)
    27. double minSize = 0.300;
    28. double maxSize = 10.0;
    29. double sizeGranularity = 0.100;
    30. double sizeBin = sizeGranularity/2.0;
    31.  
    32. int nSizes = qCeil((maxSize - minSize) / sizeBin);
    33.  
    34. double largestBin = 0.0;
    35.  
    36. QVector<Histogram *> *hists = new QVector<Histogram *>();
    37. for(int i=0;i < nSizes; i++ ) {
    38. hists->append(new Histogram() );
    39. }
    40.  
    41. /* [ load data in hists, find largest bin, clipped for brevity ...] */
    42.  
    43. layout->addWidget(plot);
    44.  
    45. QwtScaleWidget * m_rightAxis = plot->axisWidget(QwtPlot::yRight);
    46. m_rightAxis->setEnabled(true);
    47.  
    48. HistData *data = new HistData();
    49. data->setData(hists);
    50. spectrogram->setData( data );
    51. spectrogram->attach( plot );
    52.  
    53. spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, true);
    54.  
    55. QList<double> contourLevels;
    56. for ( double level = 0.5; level < 110.0; level += 15.0 )
    57. contourLevels += level;
    58. spectrogram->setContourLevels( contourLevels );
    59.  
    60. spectrogram->setDefaultContourPen( QPen() );
    61. spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, true);
    62.  
    63. const QwtInterval zInterval = spectrogram->data()->interval(Qt::ZAxis);
    64. m_rightAxis->setColorMap(zInterval, new ColorMap());
    65.  
    66. plot->setAxisScale(QwtPlot::yRight, 0.0, (double) largestBin);
    67. plot->enableAxis(QwtPlot::yRight);
    68.  
    69. plot->plotLayout()->setAlignCanvasToScales( true );
    70.  
    71. plot->replot();
    72.  
    73. dlg.show();
    74. dlg.exec();
    To copy to clipboard, switch view to plain text mode 

    The QwtRasterData::setInterval() calls are in my data class and set the ranges when the data is set with data->setData(hists). Is there any function of the QwtRasterData subclass that would in some way impact contour lines but not impact plotting of spectrogram data? My data class is pretty simple. I believe the only thing special is that I've enabled pixelHint() to return QRectF() at one point when I was having trouble.

    thanks...


    Added after 11 minutes:


    Quote Originally Posted by Uwe View Post
    maybe the levels don't match the valid range of your z-values ?
    If 1 contour level falls outside the range (and it probably would in the code the way I have it written), does it not plot any of the levels?
    Last edited by okachobi; 2nd October 2012 at 15:48.

  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: QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

    I'm afraid you need to upload a compilable example.

    Uwe

  5. #5
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

    I don't know that I can generate a simple case example, but I discovered that on larger data sets, I am seeing the contour lines, but they don't make any sense. Maybe the attached image will point to a familiar problem. Note that the contours do not match the distribution of the data being plotted...

    thanks...

    graph.jpg

  6. #6
    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: QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

    I don't see how the posted code could lead to the screenshot. That's why I guess the reason is in another part of your application.

    To make a small example you can upload here:

    1. Modify your application, so that it displays a data object with calculated points ( like in the spectrogram example )
    2. Isolate the plot widget from the rest of the application


    Cumbersome - but I don't know any other solution, beside that you start the debugger check the contour algorithm on your own.

    Uwe

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

    okachobi (4th October 2012)

  8. #7
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QwtPlotSpectrogram contour lines not visible (qwt 6.0.1)

    I'll try to pull something self-contained together that illustrates that problem and post it.

    I added some logging in my value() method from the QwtRasterData subclass since the data being plotted by the contour lines doesn't look like the Spectrogram data at all. What I've found so far is...

    - If I turn off the raster image so as to only plot the contour lines, the minimum and maximum x,y values passed to value() through the course of the replot match the range I defined with setInterval() - see below
    XAxis interval is: 1e-16 to 1e-08
    YAxis interval is: 0.3 to 9.675
    ZAxis interval is: 0 to 439
    Min/Max values for call to value(): ( 1e-16 , 0.3 ) - ( 9.98867e-09 , 9.65614 )

    - I then found a hot spot in my data that was not showing up in the contour lines and added additional logging to log any calls that occur within that bounding rectangle. The rectangle I defined was:

    (2e-12, 1.0) - (7e-12, 1.5)

    When I turn the spectrogram raster image on, I get calls to value() in this range that return non-zero data that is valid. When I turn off the raster image, and use only contour lines, I get no calls to value() for anything in this range. I do still record the min/max values of x,y for any calls to value() and they are still as reported above. So for some reason, the contour drawing routines are skipping over some segment of my data.

    - I noticed that value() is called twice with the same x,y values whether the image mode is enabled or not. The calls are always made back to back so it might be beneficial for me to cache the result of the previous interpolation....

    I suspected that perhaps my value() method wasn't thread safe, but setting the render threads to 1 produced no change in behavior.

    I'll try to generate a test case....

Similar Threads

  1. Contour correction
    By jwxiang in forum Qwt
    Replies: 2
    Last Post: 20th July 2012, 13:40
  2. QwtPlotSpectrogram and contour lines
    By toffkriss in forum Qwt
    Replies: 3
    Last Post: 8th March 2010, 10:49
  3. Help understanding QWT Contour Plot
    By jwieland in forum Qwt
    Replies: 11
    Last Post: 7th December 2009, 06:47
  4. Replies: 0
    Last Post: 15th September 2009, 02:34
  5. Replies: 3
    Last Post: 10th November 2008, 12:14

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.