Results 1 to 2 of 2

Thread: rescale to data range when reploting

  1. #1
    Join Date
    Jun 2019
    Location
    France, Pau
    Posts
    41
    Thanks
    25
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default rescale to data range when reploting

    Hello,

    I'm using this code I found on StackOverflow to fit the axis to the data range :

    Qt Code:
    1. // the canvas should be perfectly aligned to the boundaries of your curve.
    2. m_pChart->axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating, true);
    3. m_pChart->axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating, true);
    4. m_pChart->plotLayout()->setAlignCanvasToScales(true);
    To copy to clipboard, switch view to plain text mode 

    After the first replot, if I do some panning or zooming, the second replot will not fit the axis to the data range. In some cases that's fine, but there's case where I want to rescale the axis to the data range.

    So do I have to store the min/max somewhere and use QwtPlot::setAxisScale or can this be done automatically (so less code to maintain).

    Thanks.

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

    Default Re: rescale to data range when reploting

    You can assign the scale ranges manually or use autoscaling, but not both at the same time.

    As soon as you change the scales manually by setAxisScale ( what is done by panning/zooming ) autoscaling gets turned off.
    If you want to re-enable it you have to use QwtPlot::setAxisAutoScale(), what will have an effect in the next call of replot.

    Uwe

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

    embeddedmz (19th June 2019)

Similar Threads

  1. ODBC driver error QODBCResult::data: column out of range
    By Andrewgaven in forum Qt Programming
    Replies: 6
    Last Post: 16th January 2013, 10:30
  2. How to rescale the QwtPlotZoomer->canvas
    By revellix in forum Qwt
    Replies: 6
    Last Post: 7th October 2011, 14:30
  3. Replies: 2
    Last Post: 15th January 2011, 07:07
  4. Automatic rescale QwtPlotMarker
    By gpsgek in forum Qwt
    Replies: 0
    Last Post: 23rd May 2010, 17:26
  5. Replies: 3
    Last Post: 12th June 2008, 12:59

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.