• 欢迎浏览“String me = Creater\忠实的资深Linux玩家;”,请文明浏览,理性发言,有侵犯你的权益请邮件我(creater@vip.qq.com).
  • 把任何的失败都当作一次尝试,不要自卑;把所有的成功都想成是一种幸运,不要自傲。
  •    4年前 (2014-04-20)  qwt 评论关闭  15 
    文章评分 0 次,平均分 0.0

    Interval and all tick positions of a scale are stored in a QwtScaleDiv object.

    You can manually create a QwtScaleDiv and assign it to a plot axis (QwtPlot::setAxisScaleDiv()) , or you can use a QwtScaleEngine ( QwtPlot has one for each axis), that calculates it for you. When autoscaling ( QwtPlot::setAxisAutoScale() ) is enabled, the interval for the calculation of the scale is taken from the bounding rectangle of the plot items ( f.e. curves ), otherwise interval/step size are passed with QwtPlot::setAxisScale().

    The default scale engines try to calculate ticks for linear decimal scales, what doesn't need to be the right thing for date/time scales. ( QwtDateTimeScaleEngine is on my TODO list ). To improve your scale divisions you can derive and assign ( QwtPlot::setAxisScaleEngine()) your own scale engine or simply use QwtPlot::setAxisScaleDiv instead.

    QwtScaleDraw is responsible for painting a QwtScaleDiv. QwtScaleDraw::label() maps a tick value into a string.
    In the cpuplot example the values on the x-axis are seconds elapsed since the system is up. TimeScaleDraw::label() maps them into time strings - that's all.
    先改输出tick在横坐标位置,

        QList<double> ticks[QwtScaleDiv::NTickTypes];
        ticks[QwtScaleDiv::MajorTick] << 60 << 120;  //只在60和120个sample点tick
        QwtScaleDiv scaleDiv(
            ticks[QwtScaleDiv::MajorTick].first(),
            ticks[QwtScaleDiv::MajorTick].last(),
            ticks );
        plot->setAxisScaleDiv(QwtPlot::xBottom, scaleDiv);

    再改tick具体值, 需要重载QwtText label函数,

    class RealScaleDraw: public QwtScaleDraw
    {
    public:
        RealScaleDraw()
        {
        }
        virtual QwtText label(double v) const
        {
            //return QwtScaleDraw::label(v);
                return QwtText(QString::number(v/10)); //60和120都除以10
            }
    };
    

    主函数调用,

    plot->setAxisScaleDraw(QwtPlot::xBottom, new RealScaleDraw());
     

    除特别注明外,本站所有文章均为String me = "Creater\忠实的资深Linux玩家";原创,转载请注明出处来自http://unix8.net/home.php/3352.html

    关于
    切换注册

    登录

    忘记密码 ?

    切换登录

    注册

    扫一扫二维码分享