Results 1 to 9 of 9

Thread: A couple of questions about QwtRasterData/QwtMatrixRasterData

  1. #1

    Default A couple of questions about QwtRasterData/QwtMatrixRasterData

    Hello.

    I have a few questions about these two similar classes.
    Is there a way to either:
    a) display X or Y axis on a logarithmic scale,
    b) change the labels of the ticks?

    These options seem viable for basic XY plots, but I haven't found a way to utilize them with QwtRasterData/QwtMatrixRasterData.
    I want to plot a series of 3D data with a very large Y scale, so I want to either plot it in a logarithmic (or a semi-logarithmic) scale or to simply recalculate my Y axis values (newY=LogStartPoint+LogStartPoint*log10(dataPoint/LogStartPoint)) and to plot them in a linear scale with relabeled axis ticks.

  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: A couple of questions about QwtRasterData/QwtMatrixRasterData

    a) display X or Y axis on a logarithmic scale
    QwtRasterData no problem - QwtMatrixRasterData only when your matrix is somehow logarithmic too.

    b) change the labels of the ticks?
    The tick labels have nothing to with what is displayed on the canvas ( beside the autoscaler ). Set and change them to whatever you want.

    Uwe

  3. #3

    Default Re: A couple of questions about QwtRasterData/QwtMatrixRasterData

    Could you elaborate on this?

    As far as I gather, logarithmic scale can be implemented, for instance, via setAxisScaleEngine(QwtPlot::xBottom, QwtLog10ScaleEngine()). Does the same thing apply to QwtRasterData?
    The tick labels, from what I've found, can be set by QwtScaleDiv->setTicks. Again, can this also be applied to QwtRasterData? I could be mistaken on both accounts, so do correct me if I'm wrong .

  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: A couple of questions about QwtRasterData/QwtMatrixRasterData

    You don't apply scales for plot items.

    It works this way: a spectrogram iterates over all pixels translating each of them into plot coordinates. Then it gets the value from the raster data object for the translated pixel and maps it into a color. When you have a logarithmic scale you would have a different translation ( QwtScaleMap::invTransform() ), but the raster data object is not affected.

    The only job of the data object is to return values. It has nothing to do with where and how someone wants to display them.

    Uwe

  5. #5

    Default Re: A couple of questions about QwtRasterData/QwtMatrixRasterData

    Thanks, your answers really helped me out.

    I still have one question though. In order to plot a series of discrete data, I have to resample my data. I use a rather simple algorithm, which simply returns the value of an array element, that is in the vicinity (dx,dy) of the real x and y coordinates (x_data, y_data):
    Qt Code:
    1. for (int i=0;i<N;i++)
    2. for(int j=0;j<N;j++)
    3. if((fabs(x_axis[i]-x)<=dx)&&(fabs(y_axis[j]-y)<=dy))
    4. return matrix[i][j];
    To copy to clipboard, switch view to plain text mode 

    This algorithm works just fine and is easy to configure, but it is rather slow when working with big (280x280) arrays. Is there a way to speed up the plotting process for big datasets?

  6. #6
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A couple of questions about QwtRasterData/QwtMatrixRasterData

    how do you use that snippet? as I see, you calculate only one double value. do you call this snippet several times?

  7. #7

    Default Re: A couple of questions about QwtRasterData/QwtMatrixRasterData

    Quote Originally Posted by FelixB View Post
    how do you use that snippet? as I see, you calculate only one double value. do you call this snippet several times?
    Well yes. The program does it anyway. This is the core of my QwtRasterData::value function.
    I guess I should elaborate. This snippet is an example of a typical contour plot graph (right now do not pay attention to my previous questions about logarithmic scale and tick relabeling ). N x-axis values are stored it x_data, and N y-axis values are stored in y_data. Both x and y values, in this case, are equidistant (dx and dy accordingly). Amplitude values (N*N) are stored in a 2D array matrix**. Algorithm implemented in the value function simply checks whether the x an y values belong to an interval {x[i]+-dx;y[j]+-dy} and returns the appropriate value from matrix**.

  8. #8
    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: A couple of questions about QwtRasterData/QwtMatrixRasterData

    Quote Originally Posted by DizzyMoods View Post
    This algorithm works just fine and is easy to configure, but it is rather slow when working with big (280x280) arrays.
    QwtRasterData::value() is called for every pixel.Think about a plot canvas with 1000x1000 pixels and you will see soon why your code is more or less unusable. But as you wrote that you have equidistant points I don't see any reason for these loops in your code.

    Uwe

  9. #9

    Default Re: A couple of questions about QwtRasterData/QwtMatrixRasterData

    Quote Originally Posted by Uwe View Post
    QwtRasterData::value() is called for every pixel.Think about a plot canvas with 1000x1000 pixels and you will see soon why your code is more or less unusable. But as you wrote that you have equidistant points I don't see any reason for these loops in your code.
    Uwe
    Yes, I completely understand that this is how value() works and that a double loop structure is hindering the performance of my program. My question would be how to improve this algorithm for both equidistant and non-equidistant data sets.
    I guess one way to deal with equidistant data is to simply use QwtMatrixRasterData. Due to a somewhat continuous nature of x and y in QwtRasterData, previuosly given double-loop-with-a-conditional approach to me seemed like the only appropriate way to deal with 2D array data. If there's a faster implementation (for QwtRasterData) - I would be really grateful to hear it out .

Similar Threads

  1. A couple of newbie QT questions
    By fishing_boat in forum Newbie
    Replies: 17
    Last Post: 8th January 2010, 21:10
  2. Replies: 0
    Last Post: 10th October 2009, 06:44
  3. Replies: 10
    Last Post: 5th August 2009, 12:53
  4. A couple of questions on installing Qt 4.5 on Windows Xp
    By rishiraj in forum Installation and Deployment
    Replies: 2
    Last Post: 3rd April 2009, 08:44
  5. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 20:03

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.