Results 1 to 2 of 2

Thread: Using logaritmic and linear axis scale together

  1. #1
    Join Date
    Aug 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Using logaritmic and linear axis scale together

    Hey !

    I am using qwt 6.1.0. I tried:

    linEngine = new QwtLinearScaleEngine;

    logEngine = new QwtLogScaleEngine;

    these codes to make my axis logaritmic and linear. But I want use them together for examle;

    1 - 10 ---> in this interval must be linear

    10 - 10000 ---> in this interval must be logaritmic

    1.jpg

    is that possible?
    Last edited by alperyazir; 14th July 2014 at 12:18.

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

    Default Re: Using logaritmic and linear axis scale together

    You can try something like this:

    Qt Code:
    1. class MyTransform: public QwtTransform
    2. {
    3. public:
    4. MyTransform( double threshold ):
    5. m_threshold( threshold ),
    6. m_offset( threshold - log( threshold ) )
    7. {
    8. }
    9.  
    10. virtual double transform( double value ) const
    11. {
    12. double v = qAbs( value );
    13. if ( v > m_threshold )
    14. v = m_offset + log( v );
    15.  
    16. return value < 0.0 ? -v : v;
    17. }
    18.  
    19. virtual double invTransform( double value ) const
    20. {
    21. double v = qAbs( value );
    22. if ( v > m_offset )
    23. v = qExp( v ) - m_offset;
    24.  
    25. return value < 0.0 ? -v : v;
    26. }
    27.  
    28. virtual double bounded( double value ) const
    29. {
    30. return value;
    31. }
    32.  
    33. virtual QwtTransform *copy() const
    34. {
    35. return new MyTransform( m_threshold );
    36. }
    37.  
    38. private:
    39. const double m_threshold;
    40. const double m_offset;
    41. };
    42.  
    43. ...
    44. scaleEngine->setTransformation( new MyTransform( 10.0 ) );
    45. plot->setAxisScaleEngine( QwtPlot::yLeft, scaleEngine );
    46.  
    47. QwtScaleDiv scaleDiv( -10000.0, 10000.0 );
    48.  
    49. QList<double> majorTicks;
    50. majorTicks << -10000 << -1000 << -100 << -10 << -8 << -6 << -4 << -2 << 0 << 2 << 4 << 6 << 8 << 10 << 100 << 1000 << 10000;
    51. scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
    52.  
    53. plot->setAxisScaleDiv( QwtPlot::yLeft, scaleDiv );
    To copy to clipboard, switch view to plain text mode 

    If you can't set the ticks manually ( f.e. your application supports zooming ) you also have to implement your own type of QwtScaleEngine.

    Uwe

Similar Threads

  1. Replies: 1
    Last Post: 9th September 2013, 08:50
  2. qwt log scale Y and linear scale X
    By Annihilator in forum Qwt
    Replies: 1
    Last Post: 31st December 2012, 11:01
  3. qwt axis scale
    By Markus_AC in forum Qwt
    Replies: 0
    Last Post: 15th December 2011, 10:45
  4. Replies: 4
    Last Post: 16th January 2011, 11:32
  5. qwp plot axis scale
    By Cal in forum Qwt
    Replies: 1
    Last Post: 11th May 2009, 18:10

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.