PDA

View Full Version : QwtPlot fixed X-axis display



micc13
3rd December 2010, 11:30
I am displaying a large amount of data on a graph, comprising thousands of points.
I display discrete sections of the graph by modifying the X-axis scale as follows :-

setAxisScale(QwtPlot::xBottom, selectedRegion, selectedRegion+singleIncrement);

By default, the X-axis displays the X-value of the selected range, e.g. 10500 to 10600.

Is it possible to modify the X-axis display to ALWAYS show the range 0 to 100, regardless of the selected area?

Thanks.

FelixB
3rd December 2010, 11:33
of course. you set the axisScale of QwtPlot::xBottom to range 0-100. Then you have to use QwtPlot::xTop as xAxis for your data curves.

Uwe
3rd December 2010, 12:28
Is it possible to modify the X-axis display to ALWAYS show the range 0 to 100, regardless of the selected area?


I recommend to use a fixed scale of 0-100 always - but implement your own type of QwtData object, that is aware of the range changes. Beside, that you can simply subtract the minimum of the range in YourData::x() you could also reduce the number of points, that needs to be painted. When your samples are ordered in x-order identifying all points that are in the current range should be pretty fast and you can improve the performance of your plot widget heavily.

Another solution is to implement your own type of QwtScaleDraw ( check the cpuplot example ), where you manipulate the mapping of a value to its label. But this doesn't improve any performance.

Uwe

PS: When you don't want to follow my advice you should at least enable QwtPlotCurve::ClipPolygons