PDA

View Full Version : More than one errorbars in a plot??? (Qwt 6.0.1)



freeman_w
29th September 2011, 15:36
Hi folks!

I am trying to make a plot where I can show more curves that include errorbars (each has its own one).
I started at the friedberg example and made a few adjustments in the "Plot::Plot(...)" constructor.

I changed the data with something simple just to see what will happen... Here is the corresponding code:



...
const int numElements = 5;
QVector<QPointF> curve1( numElements );
QVector<QwtIntervalSample> errorbar1( numElements );
QVector<QPointF> curve2( numElements );
QVector<QwtIntervalSample> errorbar2( numElements );

for ( int i = 0; i < numElements; i++ )
{
curve1[i] = QPointF( double( i ), double( pow(i,3) ) );
errorbar1[i] = QwtIntervalSample( double( i ),
QwtInterval( pow(i,3)-i, pow(i,3)+i ));

curve2[i] = QPointF( double( 2*i ), double( pow(i,3) ) );
errorbar2[i] = QwtIntervalSample( double( 2*i ),
QwtInterval( pow(i,3)-i, pow(i,3)+i ));
}

insertCurve( "Curve 1", curve1, Qt::darkRed );
insertErrorBars( "Error-Bars 1", errorbar1, Qt::red );
insertCurve( "Curve 2", curve2, Qt::darkGreen );
insertErrorBars( "Error-Bars 2", errorbar2, Qt::green );
...


The problem is that with this way, I can't see both error bars. Only the last one is shown in the plot. Same applies if I extend to 3 curves/error bars and so on...
Only the last one is visible. More curves work. But not the error bars. So why are the other bars not there?
Why does it work with the function insertCurve() and not with insertErrorBars()?
And in the legend, on the right (see picture 6921) the symbol for the first bar also doesn't appear.

The general problem is that i can't associate a QwtIntervalSample() to a curve. I can only associate the interval to a x- or y-value.
But if i want to plot more than one curves, then how can QwtIntervalSample() know which x- or y-value I mean???
The curves may use somewhere the same values...

Is it possible to do something like that with this version of Qwt (6.0.1) ???
Or can u only have one "error bar" in a plot atm?

Thanks for some help on that one!

Uwe
29th September 2011, 16:47
Why does it work with the function insertCurve() and not with insertErrorBars()?
Both methods are part of the friedberg example not the Qwt library - check the code and you will find the answer yourself.

Of course you can have as many interval curves as you want in the same plot.

Uwe