QCustomPlot Discussion and Comments

Rescaling data on Y axisReturn to overview

I am using a graph to display values that could either be displayed in mL/min or L/min units.

Currently when the units are changed I can reset the Y axis to go from, say, 0 to 20 L/min, to 0 to 2000 mL/min. But obviously the values plotted on the graph from the L/min need to be rescaled (x1000) to display properly after changing the range.

Is there any efficient way to do this? So far I am storing the values separately and then clearing the graph and readding them after scaling, but this is obviously wasteful and inefficient.

The next minor release contains facilities to have a linear transform applied to the axis coordinates before creating the labels, which will make this possible. Further, a QCPAxisTickerSi will be introduced, which automatically applies SI prefixes (e.g. ยต, m, k, M, G, etc.) as appropriate.

Currently, you'd have to make a subclass of QCPAxisTicker and implement the transformation (it's not very hard, have a look at the QCPAxisTicker documentation for a starter).

I wouldn't recommend rescaling the data, as the data is not what changes (it should be kept e.g. at the SI base unit), it's only the display on the axis.