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);
#ifndef PLOT_H
#define PLOT_H
#include <qwt_plot.h>
#include <qwt_plot_histogram.h>
#include <qwt_plot_curve.h>
{
public:
void setData();
private:
QwtPlotHistogram* histogram;
};
#endif // PLOT_H
#ifndef PLOT_H
#define PLOT_H
#include <qwt_plot.h>
#include <qwt_plot_histogram.h>
#include <qwt_plot_curve.h>
class Plot : public QwtPlot
{
public:
Plot( QWidget *parent );
void setData();
private:
QwtPlotHistogram* histogram;
};
#endif // PLOT_H
To copy to clipboard, switch view to plain text mode
#include "plot.h"
#include <qwt_scale_engine.h>
#include <qwt_interval.h>
{
setAutoReplot( false );
this
->setAxisScale
(QwtPlot::yLeft,
1.0,
100.0,
0.25);
this
->setAxisScale
(QwtPlot::xBottom,
0.0,
100.0,
10.0);
histogram = new QwtPlotHistogram("Histogramm");
histogram
->setPen
( QPen( Qt
::black ) );
histogram
->setYAxis
( QwtPlot::yLeft );
histogram
->setXAxis
( QwtPlot::xBottom );
histogram->attach( this );
setData();
setAutoReplot( true );
}
void Plot::setData(){
QVector<QwtIntervalSample> samples(4);
samples.append(QwtIntervalSample(50.0, 0.0, 20.0));
samples.append(QwtIntervalSample(80.0, 20.0, 40.0));
samples.append(QwtIntervalSample(40.0, 40.0, 60.0));
histogram->setData(new QwtIntervalSeriesData(samples));
}
#include "plot.h"
#include <qwt_scale_engine.h>
#include <qwt_interval.h>
Plot::Plot(QWidget *parent)
: QwtPlot( parent )
{
setAutoReplot( false );
this->setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine);
this->setAxisScale(QwtPlot::yLeft, 1.0, 100.0, 0.25);
this->setAxisScale(QwtPlot::xBottom, 0.0, 100.0, 10.0);
histogram = new QwtPlotHistogram("Histogramm");
histogram->setPen( QPen( Qt::black ) );
histogram->setYAxis( QwtPlot::yLeft );
histogram->setXAxis( QwtPlot::xBottom );
histogram->attach( this );
setData();
setAutoReplot( true );
}
void Plot::setData(){
QVector<QwtIntervalSample> samples(4);
samples.append(QwtIntervalSample(50.0, 0.0, 20.0));
samples.append(QwtIntervalSample(80.0, 20.0, 40.0));
samples.append(QwtIntervalSample(40.0, 40.0, 60.0));
histogram->setData(new QwtIntervalSeriesData(samples));
}
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!?
Bookmarks