Hello,
I have data to plot either in linear scale or in semilog scale. However, part of the dataset will be negative. It is customary in the field (semiconductor physics) to plot by taking the absolute value of the data. I have my data in array of doubles, and I pass pointers using the setRawSamples function.
I dont want to apply fabs on my dataset, in order not to lose the negative info. Also it is necessary to easily flip from linear to log scale. So I would like to do it using the QwtLogTransform and the transform function. So I overloaded it in a derived class (see below). First this is not very flexible since the method is "const". Second I have a problem with the graph scale which goes to logMin (1E-150) whatever I do.
I don't understand clearly what happen here (how is the scale calculated, not using transform results ?)
Any hint welcome !
class LogTransform: public QwtLogTransform
{
public:
virtual double transform( double value ) const override
{
if (value == 0) return 0;
return log(fabs(value));
}
virtual QwtTransform *copy() const override
{
return new LogTransform();
}
};
and also, where the log scale is applied :
QwtLogScaleEngine* scaleEngine = new QwtLogScaleEngine();
scaleEngine->setTransformation( new LogTransform() );
class LogTransform: public QwtLogTransform
{
public:
virtual double transform( double value ) const override
{
if (value == 0) return 0;
return log(fabs(value));
}
virtual QwtTransform *copy() const override
{
return new LogTransform();
}
};
and also, where the log scale is applied :
QwtLogScaleEngine* scaleEngine = new QwtLogScaleEngine();
scaleEngine->setTransformation( new LogTransform() );
To copy to clipboard, switch view to plain text mode
Bookmarks