PDA

View Full Version : setAxisAutoScale(QwtPlot::yRight) //doesn't work :(



Times
7th April 2008, 16:09
Hi all!

Could you, please, help me?:)

I've enabled yLeft and yRight on the QwtPlot.
I'm using setAxisAutoScale and it works for yLeft, but the labels on yRight are not changing in the same way like yLeft does.... (actually, they're not changing at all, in AutoScale mode)

But it works fine with logScale...

Am I did something wrong?..

basically, here is the code:


if (baseWidget->isYLogScale()) {
scaleEngineLeft = new QwtLog10ScaleEngine();
scaleEngineRight = new QwtLog10ScaleEngine();
}
else {
scaleEngineLeft = new QwtLinearScaleEngine();
scaleEngineRight = new QwtLinearScaleEngine();
}

plot->setAxisScaleEngine(QwtPlot::yLeft, scaleEngineLeft);
plot->setAxisScaleEngine(QwtPlot::yRight, scaleEngineRight);

if (baseWidget->isYAutoScale()) {
plot->setAxisAutoScale(QwtPlot::yLeft);
plot->setAxisAutoScale(QwtPlot::yRight); //TODO: doesn't work :(
}
else {
plot->setAxisScale(QwtPlot::yLeft, baseWidget->getYMin(), baseWidget->getYMax());
plot->setAxisScale(QwtPlot::yRight, baseWidget->getYMin(), baseWidget->getYMax());
}

thanx a lot!!
Tim.

Uwe
8th April 2008, 10:44
I've enabled yLeft and yRight on the QwtPlot.
I'm using setAxisAutoScale and it works for yLeft, but the labels on yRight are not changing in the same way like yLeft does.... (actually, they're not changing at all, in AutoScale mode)

The scales are calculated from the bounding rectangles of the plot items ( here your curves ), that are attached to it. If your curves are attached to the left axis they have no effect for the right axis.

You can't attach a plot item to 2 y axes. So you have to synchronize the second y axis manually, or you insert an invisible dummy curve for the second y axis with the same bounding rect.

Uwe

Times
8th April 2008, 13:48
Ok, thanks, but how can I synchronize the second y axis manually?
is there something like
"QwtPlot::getAxisScale (int axisId, double min, double max, double stepSize)" ?
so, as far as i understand, i need these min, max and stepSize to do setAxisScale for the second y axis...

in qwt_plot.h I found private class PrivateData; PrivateData *d_data;
and private class AxisData; AxisData *d_axisData[axisCnt];

Uwe
8th April 2008, 14:09
These parameters are used for the calculation of the scale. The result of the calculation is a QwtScaleDiv. There are getters for the parameters, but you don't need to calculate the QwtScaleDiv twice.

Probably the easiest way to synchronize the axes is to catch the scaleDivChanged signal of the left axis widget and to assign its QwtScaleDiv to the right one.

Uwe

haroland
17th June 2014, 10:12
I'm having the same problem. It seems that a Qwt5.QwtPlotCurve is attached to yLeft by default. I would like to attach the curve to the yRight instead, is there an easy way to do it?

Uwe
17th June 2014, 16:20
curve->setYAxis( QwtPlot::yRight );

Uwe