Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qwt plot auto scale not working

Tags:

c++

qt

qwt

I'm trying to plot some data using qt 4.8 and qwt 6, but my curves doesn't scales over plot (1).

This is how I attach curves to plot:

curves[moduleIndex][channelIndex]->setSamples(samples, data);
curves[moduleIndex][channelIndex]->attach(plots[moduleIndex][channelIndex]);

samples and data is QVectors and samples.size() is equal to data.size()

plots[moduleIndex][channelIndex]->axisAutoScale(QwtPlot::xBottom) returns true, so autoScale is enabled.

So am I missing something?

qwt plot auto scale

UPDATE: I thought that the problem occures because disabled axis

plots[i][j]->enableAxis(QwtPlot::yLeft, false);
plots[i][j]->enableAxis(QwtPlot::xBottom, false);

But I've commented it out and it didn't help.

qwt plot auto scale with axis

like image 435
Stepan Kuzmin Avatar asked Feb 23 '26 18:02

Stepan Kuzmin


1 Answers

I believe 'autoscale' is alreadyworking. But to make axis look nice, it takes a rounded number for maximum which is causing a gap at the end. Scales of QwtPlot are managed by QwtScaleEngine. You can get a pointer to default scaleEngine your plot using with QwtPlot::axisScaleEngine(...). Setting Floating attribute to true will remove this gap and will fit your data to boundaries. See docs: http://qwt.sourceforge.net/class_qwt_scale_engine.html

Ex:

plot.axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating,true);
like image 71
HeyYO Avatar answered Feb 26 '26 06:02

HeyYO



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!