Results 1 to 2 of 2

Thread: Spectrogram QwtMatrixRasterData or QwtRasterData for heatmap

  1. #1
    Join Date
    Feb 2017
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Spectrogram QwtMatrixRasterData or QwtRasterData for heatmap

    Hi,
    I'm trying to reproduce, using QwtPlotSpectrogram(), the below heatmap I generate with gnuplot with a 11x3 matrix.
    GnuPlot:
    heatmap.jpg

    I tried using the QwtMatrixRasterData example from rasterview but it does not produce the desired result, partly I dont understand the call to
    Qt Code:
    1. setValueMatrix
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. setValueMatrix( values, numColumns );
    To copy to clipboard, switch view to plain text mode 
    When I set numColumns to 3 i get the following
    raster.jpg

    I don't filly understand what numColumns represents, I guess I expected to be able to specify rows as well. Does this assume a square matrix? If so, my approach wont work. Can anyone offer alternatives?

    ------

    For using the QwtRasterData from what I understand I need to do some interpolation to make up for the missing samples (1-21 in this case), but I assuming there is an easier way to accomplish this.
    If using QwtRasterData is the best solution, is there some examples of doing this interpolation in the qwt library?


    ---

    I guess I wrongly assumed I could simply give qwt my value array like in gnuplot

    GnuPlot and Dataset

    GnuPlot code:
    set grid
    set xrange [0.100000:1.100000]
    set yrange [21.000000:1.000000]
    splot 'data.txt' u 1:2:3

    data.txt:


    Qt Code:
    1. 0.100000, 1.000000, 3.961006e-01 ,
    2. 0.350000, 1.000000, 4.056773e-01 ,
    3. 0.600000, 1.000000, 4.002060e-01 ,
    4. 0.850000, 1.000000, 3.916524e-01 ,
    5. 1.100000, 1.000000, 3.706545e-01 ,
    6.  
    7. 0.100000, 3.000000, 4.138943e-01 ,
    8. 0.350000, 3.000000, 4.219804e-01 ,
    9. 0.600000, 3.000000, 4.414663e-01 ,
    10. 0.850000, 3.000000, 4.344157e-01 ,
    11. 1.100000, 3.000000, 4.082316e-01 ,
    12.  
    13. 0.100000, 5.000000, 4.176135e-01 ,
    14. 0.350000, 5.000000, 4.047457e-01 ,
    15. 0.600000, 5.000000, 3.547628e-01 ,
    16. 0.850000, 5.000000, 3.814327e-01 ,
    17. 1.100000, 5.000000, 5.345204e-01 ,
    18.  
    19. 0.100000, 7.000000, 6.705083e-01 ,
    20. 0.350000, 7.000000, 7.008015e-01 ,
    21. 0.600000, 7.000000, 7.135350e-01 ,
    22. 0.850000, 7.000000, 6.942971e-01 ,
    23. 1.100000, 7.000000, 6.962008e-01 ,
    24.  
    25. 0.100000, 9.000000, 7.083215e-01 ,
    26. 0.350000, 9.000000, 7.187862e-01 ,
    27. 0.600000, 9.000000, 7.438571e-01 ,
    28. 0.850000, 9.000000, 7.375866e-01 ,
    29. 1.100000, 9.000000, 7.027660e-01 ,
    30.  
    31. 0.100000, 11.000000, 7.438123e-01 ,
    32. 0.350000, 11.000000, 7.601945e-01 ,
    33. 0.600000, 11.000000, 7.603712e-01 ,
    34. 0.850000, 11.000000, 7.570338e-01 ,
    35. 1.100000, 11.000000, 6.954288e-01 ,
    36.  
    37. 0.100000, 13.000000, 5.189954e-01 ,
    38. 0.350000, 13.000000, 3.377402e-01 ,
    39. 0.600000, 13.000000, 2.499562e-01 ,
    40. 0.850000, 13.000000, 2.828628e-01,
    41. 1.100000, 13.000000, 2.580383e-01 ,
    42.  
    43. 0.100000, 15.000000, 3.599443e-01,
    44. 0.350000, 15.000000, 3.406876e-01,
    45. 0.600000, 15.000000, 3.312631e-01,
    46. 0.850000, 15.000000, 3.059320e-01,
    47. 1.100000, 15.000000, 2.826419e-01,
    48.  
    49. 0.100000, 17.000000, 2.545738e-01,
    50. 0.350000, 17.000000, 2.404622e-01,
    51. 0.600000, 17.000000, 2.292019e-01,
    52. 0.850000, 17.000000, 2.083252e-01,
    53. 1.100000, 17.000000, 1.900557e-01,
    54.  
    55. 0.100000, 19.000000, 2.103311e-01,
    56. 0.350000, 19.000000, 2.060483e-01,
    57. 0.600000, 19.000000, 1.775154e-01,
    58. 0.850000, 19.000000, 2.086869e-01,
    59. 1.100000, 19.000000, 2.296807e-01,
    60.  
    61. 0.100000, 21.000000, 1.912159e-01,
    62. 0.350000, 21.000000, 2.135166e-01,
    63. 0.600000, 21.000000, 2.132891e-01,
    64. 0.850000, 21.000000, 2.133528e-01,
    65. 1.100000, 21.000000, 2.132450e-01
    To copy to clipboard, switch view to plain text mode 


    Thanks for your time
    Last edited by jeffL1349; 6th June 2017 at 22:42.

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

    Default Re: Spectrogram QwtMatrixRasterData or QwtRasterData for heatmap

    As far as I can see the posted data is a matrix of 5x11 values. The size of a data pixel seems to be 0.25x2.0, what would result in [0.10 - 0.5 x 0.25, 1.1 + 0.5 x 0.25] as horizontal and [0, 22] as vertical interval.
    If this matches the structure of your data you could use QwtMatrixRasterData. The advantage over QwtRasterData is, that you get the resampling/interpolation for free.

    But if your data is irregular ( no data pixels ) you have to use QwtRasterData and you have to do the resampling by overloading QwtRasterData::value(). It depends on what type of resampling you need, but at least nearest neighbour is question of very few lines only.

    Uwe

Similar Threads

  1. Replies: 2
    Last Post: 5th November 2016, 17:14
  2. Replies: 5
    Last Post: 9th March 2013, 14:25
  3. Using Qt to display a interactive heatmap
    By chrisb123 in forum Newbie
    Replies: 2
    Last Post: 11th November 2011, 08:56
  4. Replies: 8
    Last Post: 2nd November 2011, 17:31
  5. Bugs in QwtMatrixRasterData?
    By alex_sh in forum Qwt
    Replies: 13
    Last Post: 23rd January 2011, 12:59

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.