简体   繁体   English

Qwt 重缩放轴

[英]Qwt rescale axis

I have a QwtPlot that I wish to alter the axis scale without having to change the value of the points drawn themselves.我有一个 QwtPlot,我希望改变轴比例而不必更改自己绘制的点的值。

In my application I plot points in Volts, inside a [-10,10] V range (both axes).在我的应用程序中,我以伏特为单位绘制点,在 [-10,10] V 范围内(两个轴)。 I'd like to calibrate each axis by multiplying it by a value in nm/V to convert the scale to nanometers.我想通过将每个轴乘以一个以 nm/V 为单位的值来校准每个轴,以将刻度转换为纳米。 I'd like to do this without having to alter the value of the points themselves.我想这样做而不必改变点本身的价值。 What would be the most pratical way of getting this done?完成这项工作的最实用方法是什么?

Thanks谢谢

qwt is not going to allow you to change the axis values without affecting the data. qwt 不允许您在不影响数据的情况下更改轴值。 What you can do however, is change the axis labels .但是,您可以做的是更改轴标签 This will give you the apparent scaling affect you are looking for, but without having to manipulate your data at all.这将为您提供您正在寻找的明显缩放效果,但根本无需操作您的数据。

class QConversionScaleDraw : public QwtScaleDraw
{
public:

    explicit QConversionScaleDraw(double conversionFactor)
    : m_conversionFactor(conversionFactor)
    {

    }

    virtual QwtText label(double value) const override;
    {
        return QwtScaleDraw::label(value * m_conversionFactor);
    }

private:

    double m_conversionFactor;                                                

};

Then to use it:然后使用它:

QwtPlot myplot;
double nmToV = 0.612; // or whatever
myplot->setAxisScaleDraw(xBottom, new QConversionScaleDraw(nmToV));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM