PDA

View Full Version : Arbitrary X-Axis Scale Using Equation?



russdot
12th January 2015, 23:55
I have a plot where I would like to set an arbitrary scale on the X-axis (defined using a linear equation). How can I achieve this?

More details:
I have a spectrum, where the X-axis is "channels" (integers, from 0-2048 or however many channels are present) and the Y-axis is "counts". I would like to convert the X-axis scale to "energy" (channel converted to energy, using a linear equation). I've been experimenting with inheriting QwtTransform, defining the virtual methods transform() and invTransform(), then setting

this->axisScaleEngine(QwtPlot::xBottom)->setTransformation(new MyTransform())
but to no avail. Am I on the right track?

Thanks!

Uwe
13th January 2015, 09:30
QwtTransform is for the mapping between the axis and widget coordinate systems, but you are looking for mapping the x coordinates of your samples into the coordinate system of your x axis - that's a different one !
Don't know about the details of your project, but to me it looks like you should set up your plot coordinate system based on energy. The mapping of your samples would be done then by overloading methods of QwtSeriesData<QPointF> to return energy.

Uwe

russdot
14th January 2015, 04:52
Thanks for the reply, Uwe. I've gone with that approach and just mapped the new values, then replot - seems to be working!
Cheers