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 !


Qt Code:
  1. class LogTransform: public QwtLogTransform
  2. {
  3. public:
  4.  
  5. virtual double transform( double value ) const override
  6. {
  7. if (value == 0) return 0;
  8. return log(fabs(value));
  9. }
  10.  
  11. virtual QwtTransform *copy() const override
  12. {
  13. return new LogTransform();
  14. }
  15.  
  16. };
  17.  
  18. and also, where the log scale is applied :
  19.  
  20. QwtLogScaleEngine* scaleEngine = new QwtLogScaleEngine();
  21. scaleEngine->setTransformation( new LogTransform() );
To copy to clipboard, switch view to plain text mode