QWT plot with autoscaling shows negative values in y-axis
-
Hi,
I have a QWT plot which shows only positive data values as a curve. I want autoscaling to be done since the values are not fixed in a range. But when autoscaling is enabled for y-left axis, then y-axis starts with negative values. how can i avoid this?
setAxisAutoScale(QwtPlot::yLeft,true);
I tried changing void QwtPlot::updateAxes() in my own class but facing issues because of d_axisData[axisId] private data.
Thanks
-
I would expect that there is some savety margin around the envelope defined through your data. Typically you do not want to see that your values are hitting the frame of your plot. Therefore, you need to have some room around your actual envelope. When you curves are actually starting at 0, this margin would require the axis to start in the negative range.
Possibly the scale engine may help you in that respect, but I simply do not know.
Note: QWT is not part of Qt but a third party library based on Qt. Typically there is little response here in the forum. The original author of QWT Uwe answered before some questions, but I have not noticed responses from him lately. Personally I would try on the qwt mailing list for such questions. There you have probably more chances.
Hope this helps.
-
I have overridden the autoscale as follows
autoScale(int maxSteps,
double &x1, double &x2, double &stepSize) const
{
QwtInterval interval(x1, x2);
interval = interval.normalized();interval.setMinValue(interval.minValue() - lowerMargin()); interval.setMaxValue(interval.maxValue() + upperMargin()); if (testAttribute(QwtScaleEngine::Symmetric)) { interval = interval.symmetrize(reference()); } if (testAttribute(QwtScaleEngine::IncludeReference)) { interval = interval.extend(reference()); } if (interval.width() == 0.0) { interval = buildInterval(interval.minValue()); } stepSize = QwtScaleArithmetic::divideInterval(interval.width(), qMax(maxSteps, 1), base()); if (!testAttribute(QwtScaleEngine::Floating)) { interval = align(interval, stepSize); } x1 = 0.0; x2 = interval.maxValue(); if (testAttribute(QwtScaleEngine::Inverted)) { qSwap(x1, x2); stepSize = -stepSize; }
and this serves my purpose