Results 1 to 3 of 3

Thread: Problem of using QwtLog10ScaleEngine with QwtPlotHistogram

  1. #1
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Problem of using QwtLog10ScaleEngine with QwtPlotHistogram

    Version: qwt 6.0.1
    I've tried to develop logarithmic scaling for Histogram (As it works fine for curve, actually).
    But the error is that the data are not drawn, so the plot is empty.

    I've used simple line to enable scaling plot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);

    Qt Code:
    1. #ifndef PLOT_H
    2. #define PLOT_H
    3.  
    4. #include <qwt_plot.h>
    5. #include <qwt_plot_histogram.h>
    6. #include <qwt_plot_curve.h>
    7.  
    8.  
    9. class Plot : public QwtPlot
    10. {
    11. public:
    12. Plot( QWidget *parent );
    13.  
    14. void setData();
    15.  
    16. private:
    17. QwtPlotHistogram* histogram;
    18.  
    19. };
    20. #endif // PLOT_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "plot.h"
    2. #include <qwt_scale_engine.h>
    3. #include <qwt_interval.h>
    4.  
    5. Plot::Plot(QWidget *parent)
    6. : QwtPlot( parent )
    7. {
    8. setAutoReplot( false );
    9.  
    10. this->setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
    11. this->setAxisScale(QwtPlot::yLeft, 1.0, 100.0, 0.25);
    12. this->setAxisScale(QwtPlot::xBottom, 0.0, 100.0, 10.0);
    13.  
    14. histogram = new QwtPlotHistogram("Histogramm");
    15. histogram->setPen( QPen( Qt::black ) );
    16. histogram->setYAxis( QwtPlot::yLeft );
    17. histogram->setXAxis( QwtPlot::xBottom );
    18. histogram->attach( this );
    19.  
    20. setData();
    21.  
    22. setAutoReplot( true );
    23.  
    24. }
    25.  
    26. void Plot::setData(){
    27. QVector<QwtIntervalSample> samples(4);
    28. samples.append(QwtIntervalSample(50.0, 0.0, 20.0));
    29. samples.append(QwtIntervalSample(80.0, 20.0, 40.0));
    30. samples.append(QwtIntervalSample(40.0, 40.0, 60.0));
    31. histogram->setData(new QwtIntervalSeriesData(samples));
    32. }
    To copy to clipboard, switch view to plain text mode 

    But in result I've an empty plot (see in attachments)! Could somebody help me, please!?
    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: Problem of using QwtLog10ScaleEngine with QwtPlotHistogram

    In vertical direction the histogram draws bars from the baseline to the value for each sample. The default value for the baseline is 0.0, what is an invalid value for a logarithmic scale - that's why no bars are displayed at all.

    After setting a valid baseline ( f.e. histogram->setBaseline( LOG_MIN ) ) you will see the missing bars.

    Uwe

    PS: The vector from your example code consists of 7 samples, where the first 4 are initialized with default ( also invalid ) values.

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

    lunatik-210 (11th July 2012)

  4. #3
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem of using QwtLog10ScaleEngine with QwtPlotHistogram

    Thank you, it works!!

    ps Yeah, it my fault about vector size

Similar Threads

  1. QwtPlotHistogram question
    By fantom in forum Qwt
    Replies: 3
    Last Post: 28th March 2013, 09:43
  2. Problems with QwtLog10ScaleEngine
    By Gordey1978 in forum Qwt
    Replies: 3
    Last Post: 28th September 2011, 07:06
  3. QwtKnob and QwtLog10ScaleEngine
    By F. H. Saad in forum Newbie
    Replies: 1
    Last Post: 13th July 2011, 11:21
  4. QwtPlotHistogram
    By yers in forum Qwt
    Replies: 4
    Last Post: 5th January 2011, 07:23
  5. Replies: 4
    Last Post: 4th January 2011, 09:47

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