Custom X-axis scale, auto-scale Y-axis for many Curves
I'm building a real-time plot that updates a few times a second and shows a particular window of data (usually the end of the plot) specified by an X-value range (usually from Last-N to Last). My initial approach was to iterate through each of the Curves (for which there are up to 25) and calculate the plot's boundingRect before each replot.
After reading some posts on the forum, I decided a better approach would be to simply use setAxisScale on the QwtPlot for the x-axis and hopefully the QwtPlot would be smart enough to properly scale the Y-Axis to fit the data. While the x-axis scale looks correct, the y-axis is always set to the min/max of my whole dataset and is not restricted to just the data within the custom x-axis bounds.
Am I missing something?
My code is basically:
setAxisScale(xButtom, 0.0, 200.0, 0);
setAxisAutoScale(yLeft);
Any help on this is appreciated.
Re: Custom X-axis scale, auto-scale Y-axis for many Curves
Quote:
Originally Posted by
unomystEz
While the x-axis scale looks correct, the y-axis is always set to the min/max of my whole dataset and is not restricted to just the data within the custom x-axis bounds
Yes this is exactly how the autoscaler works - it uses the interval from the bounding rectangle of the curve.
In your case autoscaling doesn't make any sense and you better calculate the range for the y axis, when setting the range for the x axis - also using setAxisScale() for the y axis. As your points are ordered according to the x coordinates qwtUpperSampleIndex() might help for finding the samples you have to iterate.
But be aware, that your approach will result in a plot that jumps heavily - several times a second !
Uwe