Results 1 to 4 of 4

Thread: Axis not aligning with Spectrogram image

  1. #1
    Join Date
    May 2010
    Posts
    24
    Thanks
    14
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Axis not aligning with Spectrogram image

    Hello,

    I cant get the axis to align properly to the plot (see attached image). I'd like the ticks to be centered on the data bins -- not on the left side of the data bin. I've tried aligning the canvas to the axis, changing margins, and adjusting the axis -- all with no luck.

    I am using Qwt5.2.0 on FC6. I can also post the code, if that would help -- but it was take almost verbatim from the spectrogram example code.
    Attached Images Attached Images

  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: Axis not aligning with Spectrogram image

    Obviously your data bins cover squares with a size of 1, f.e one square is from 5-6, 10-11. So if you want to have a ticks centered its positions need to be 5.5, 10.5.

    But I guess what you really want is a square at 4.5-5-5, 9.5.10.5 - probably by using qRound() instead of floor ( = casting to int ) in YourRasterData::value().

    Uwe

    PS: If the resolutions of your data is 1x1 don't forget to implement YourRasterData::rasterHint(). It will make the rendering process much faster.

  3. #3
    Join Date
    May 2010
    Posts
    24
    Thanks
    14
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Axis not aligning with Spectrogram image

    Quote Originally Posted by Uwe View Post
    Obviously your data bins cover squares with a size of 1, f.e one square is from 5-6, 10-11. So if you want to have a ticks centered its positions need to be 5.5, 10.5.

    But I guess what you really want is a square at 4.5-5-5, 9.5.10.5 - probably by using qRound() instead of floor ( = casting to int ) in YourRasterData::value().

    Uwe

    PS: If the resolutions of your data is 1x1 don't forget to implement YourRasterData::rasterHint(). It will make the rendering process much faster.
    Thanks for your reply Uwe. I modified my code to use qRound -- I also had to change the axis and the spectrograms bounding rect. The attached plot shows the result (it looks good!).

    I dont quite understand your advice about rasterHint -- very much a graphics novice here. I am going to look through the examples to see if I can figure out what you mean. Btw, each data point (bin) of my data should be square (though I can live with rectangles!).
    Attached Images Attached Images

  4. #4
    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: Axis not aligning with Spectrogram image

    I dont quite understand your advice about rasterHint -- very much a graphics novice here..
    Obviously your data has a resolution of 1.0x1.0 and the image above could be rendered with something about 35x48 ( = 1680 ) values.

    Without any information about the resolution YourData::value() has to be called for each position corresponding to a pixel. F.e. for a widet with 1000x1000 pixels it means 1000000 values will be collected to render the ~same image. When printing in high resolution you will have even much more points ...

    Btw, each data point (bin) of my data should be square (though I can live with rectangles!).
    The ratio of your rectangles always corresponds to your scales. Have a look at QwtPlotRescaler ( in svn trunk you find an example called "navigation" using it ) if you want to set a fixed ratio ( f.e 1:1 ). It is a helper, that tries to auto-adjust the scales according to the size of the plot canvas.

    Uwe

Similar Threads

  1. get min and max value from spectrogram
    By rambo83 in forum Qwt
    Replies: 1
    Last Post: 2nd December 2009, 15:25
  2. qwt spectrogram example
    By rambo83 in forum Qwt
    Replies: 2
    Last Post: 17th November 2009, 22:13
  3. Aligning widgets in different layouts
    By negritot in forum Qt Tools
    Replies: 4
    Last Post: 9th March 2009, 17:07
  4. Aligning message displayed on QStatusbar
    By sanjayshelke in forum Qt Programming
    Replies: 2
    Last Post: 20th November 2008, 10:41
  5. Aligning a stringlist
    By impeteperry in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2006, 18:45

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.