Results 1 to 8 of 8

Thread: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

  1. #1
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    Hello,

    i'm using a logarithmic y-Axis like this:

    Qt Code:
    1. class LogScaleDraw : public QwtScaleDraw
    2. {
    3. public:
    4. LogScaleDraw() : QwtScaleDraw(){
    5. }
    6.  
    7. virtual QwtText label(double value) const
    8. {
    9. return QString::number(value, 'E', 3);
    10. }
    11. };
    12.  
    13. pyLogScaleEngine = new QwtLogScaleEngine;
    14. pyLogScaleDraw = new LogScaleDraw;
    15. setAxisScaleEngine( QwtPlot::yLeft, pyLogScaleEngine );
    16. setAxisScaleDraw( QwtPlot::yLeft, pyLogScaleDraw );
    17. setAxisMaxMajor( QwtPlot::yLeft, 15 );
    18. setAxisMaxMinor( QwtPlot::yLeft, 10 );
    To copy to clipboard, switch view to plain text mode 

    It is possible to load our data into a plot and sometimes (with low delta y) the
    lables on the y-axis are not painted (or not visible). It seems to be independ
    from the absolut value, e.g. even if i have a low delta y within a -5 decade of pressure
    the lables are not visible.

    Any ideas?
    Thx
    Attached Images Attached Images

  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: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    Well, as long as we are not talking about deltas, that are below the significance of doubles, I don't see why it should not be possible to display a valid scale.
    For logarithmic scales there is indeed a minimum of 1.0e-150 and a maximum of 1.0e+150 - hardcoded in QwtLogTransform.

    What is the exact range, that leads to the bad scale in your case ?

    Uwe

  3. #3
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    Hello Uwe,

    we get our data vom vacuum transmitter and the range is normaly between 2000 and 1E-10, and if
    the data changes over time or the loaded data is e.g. from 995 to 1e-4, we don't have a problem.

    But if the pressure value is nearly constant, means ymin=0.955 and ymax=0.956 for 1 minute e.g.,
    we don't see a scale (right scale in attached picture).
    If found in QwtLogScaleEngine, that it will be checked if the delta Y is lower that logBase and that happens
    in our case. In qwt_scale_engine.cpp we jump into this, because we have less than on step i guess:

    line 814 to 838 from qwt_scale_engine.cpp:
    Qt Code:
    1. if ( interval.maxValue() / interval.minValue() < logBase )
    2. {
    3. // scale width is less than one step -> try to build a linear scale
    4.  
    5. QwtLinearScaleEngine linearScaler;
    6. linearScaler.setAttributes( attributes() );
    7. linearScaler.setReference( reference() );
    8. linearScaler.setMargins( lowerMargin(), upperMargin() );
    9.  
    10. linearScaler.autoScale( maxNumSteps, x1, x2, stepSize );
    11.  
    12. QwtInterval linearInterval = QwtInterval( x1, x2 ).normalized();
    13. linearInterval = linearInterval.limited( LOG_MIN, LOG_MAX );
    14.  
    15. if ( linearInterval.maxValue() / linearInterval.minValue() < logBase )
    16. {
    17. // the aligned scale is still less than one step
    18. if ( stepSize < 0.0 )
    19. stepSize = -qwtLog( logBase, qAbs( stepSize ) );
    20. else
    21. stepSize = qwtLog( logBase, stepSize ); // THIS IS CALLED FINALY
    22.  
    23. return;
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    The interessing point is, if i zoom in OR our with QwtMagnifier i can see the scale again.
    Thx

  4. #4
    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: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    Which min/max values lead errors ?

    Uwe

  5. #5
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    Hello Uwe,

    we made a subclass ob QwtLogScaleEngine and change some code

    line 909 to 915:

    Qt Code:
    1. if ( stepSize != 0.0 )
    2. {
    3. if ( stepSize < 0.0 )
    4. // stepSize = -qPow( logBase, -stepSize ); // NOT WORKING
    5. stepSize = 0; // WORKING
    6. else
    7. stepSize = qPow( logBase, stepSize );
    8. }
    To copy to clipboard, switch view to plain text mode 

    If the stepSize is negative, we set it to zero and everything is fine.

    Is that maybe a general bug of Qwt?

    Thx

  6. #6
    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: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    Again: please provide a min/max combination, that leads to errors ?

    Uwe

  7. #7
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    The ranges are in the picture in first post:
    e.g from picture ymin=0.955, ymax= 0.956

    Stefan

  8. #8
    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: Logarithmic Y-Axis, no lables visible with low delta Y (ymax-ymin)

    I tried the following code with Qwt from SVN ( 6.1 branch ):

    Qt Code:
    1. #include <qapplication.h>
    2. #include <qwt_plot.h>
    3. #include <qwt_scale_engine.h>
    4.  
    5. int main( int argc, char **argv )
    6. {
    7. QApplication a( argc, argv );
    8.  
    9. QwtPlot plot;
    10. plot.setTitle( "Plot Demo" );
    11. plot.setCanvasBackground( Qt::white );
    12.  
    13. plot.setAxisScaleEngine( QwtPlot::yLeft, new QwtLogScaleEngine );
    14. plot.setAxisMaxMajor( QwtPlot::yLeft, 15 );
    15. plot.setAxisMaxMinor( QwtPlot::yLeft, 10 );
    16. plot.setAxisScale( QwtPlot::yLeft, 0.955, 0.956 );
    17.  
    18. plot.resize( 600, 400 );
    19. plot.show();
    20.  
    21. return a.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 
    At least [0.955, 0.956] does not seem to be a problem.

    Uwe

Similar Threads

  1. Replies: 0
    Last Post: 8th August 2015, 17:52
  2. recalculate lables in QwtScaleDraw
    By tavla in forum Qwt
    Replies: 1
    Last Post: 1st November 2013, 12:51
  3. logarithmic scales
    By sergio486 in forum Qwt
    Replies: 2
    Last Post: 22nd December 2010, 17:05
  4. Mastering signals; what's your opinion on Delta Object Rules?
    By piotr.dobrogost in forum Qt Programming
    Replies: 1
    Last Post: 14th October 2009, 13:05
  5. logarithmic scale
    By Times in forum Qwt
    Replies: 2
    Last Post: 1st July 2008, 15:41

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.