Results 1 to 11 of 11

Thread: Arbitrary axis interval without affecting the plot

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Arbitrary axis interval without affecting the plot

    Thank you for your replies. My task is to create a clone for the Matlab imagesc() which has one form where one can specify the axis extents in the arguments.

    Would the following code theoretically change the x-axis to range from -100 to 20? As it is, the code here still allows the x-axis to be drawn from 0 to 127, and the plot shows up compressed and on the right hand side.
    Qt Code:
    1. class RD_Qwt_Plot : public QwtPlotSpectrogram
    2. {
    3. public:
    4. RD_Qwt_Plot()
    5. {
    6. setItemAttribute(QwtPlotItem::AutoScale, false);
    7. }
    8.  
    9. ~RD_Qwt_Plot()
    10. {
    11. }
    12.  
    13. virtual void draw(QPainter* painter, const QwtScaleMap &xMap,
    14. const QwtScaleMap &yMap, const QRectF &canvasRect) const
    15. {
    16. QwtScaleMap cust_x_map;
    17. cust_x_map.setPaintInterval(xMap.p1(), xMap.p2());
    18. // Matrix spans 128 for the X direction
    19. // cust_x_map.setScaleInterval(0, 127);
    20. cust_x_map.setScaleInterval(-100, 20);
    21.  
    22. QwtScaleMap cust_y_map;
    23. cust_y_map.setPaintInterval(yMap.p1(), yMap.p2());
    24. // Matrix spans 16384 for the Y direction
    25. cust_y_map.setScaleInterval(0, 16383);
    26.  
    27. QwtPlotSpectrogram::draw(painter, cust_x_map, cust_y_map, canvasRect);
    28.  
    29. }
    30.  
    31. /*
    32.   // This method is referenced when checking to see what data to be plotted.
    33.   // If you set the interval here, it changes both the axis and the
    34.   // data plotted.
    35.   QwtInterval interval(Qt::Axis axis) const
    36.   {
    37.   const QwtInterval interv(-34, 67);
    38.   return interv;
    39.   }
    40. */
    41. };
    To copy to clipboard, switch view to plain text mode 

    Here is a screen shot of what currently happens.
    cap.jpg

    Thanks

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

    Default Re: Arbitrary axis interval without affecting the plot

    Quote Originally Posted by parasonic View Post
    My task is to create a clone for the Matlab imagesc() which has one form where one can specify the axis extents in the arguments.
    See QwtPlot::setAxisScale() and check the spectrogram example how to eliminate the margins. If you want to limit the area, where to display your spectrogram see QwtRasterData::setInterval().

    What the heck is your motivation to manipulate the canvas maps ?

    Uwe
    Last edited by Uwe; 21st September 2011 at 08:19.

Similar Threads

  1. Replies: 9
    Last Post: 3rd May 2011, 21:21
  2. Is it possible to draw axis in Plot?
    By beni46 in forum Qwt
    Replies: 2
    Last Post: 26th January 2010, 12:54
  3. x-axis for waterfall plot
    By janK in forum Qwt
    Replies: 8
    Last Post: 29th July 2009, 15:00
  4. qwp plot axis scale
    By Cal in forum Qwt
    Replies: 1
    Last Post: 11th May 2009, 17:10
  5. Detecting changes in the qwt plot axis
    By mrcolin in forum Qwt
    Replies: 2
    Last Post: 27th January 2009, 12:53

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
  •  
Qt is a trademark of The Qt Company.