【问题标题】:qwt plot curve axis not visibleqwt 绘图曲线轴不可见
【发布时间】:2011-12-28 11:52:25
【问题描述】:

我正在使用 qwt plot curve 来绘制曲线。 x 轴和 y 轴不可见,只有曲线可见。 如何通过显示一些第一个、最后一个和中间值来显示轴 轴的刻度间隔

【问题讨论】:

标签: c++ qt qwt


【解决方案1】:

我给你举个小例子:

   // xBottom - x-axis yBottom - y-axis

    plot->setAxisMaxMinor(QwtPlot::xBottom, 2);
    plot->setAxisScale(QwtPlot::xBottom, 0, MAX_X_VALUE, 2);
    plot->setAxisMaxMinor(QwtPlot::yLeft, 2);
    plot->setAxisScale(QwtPlot::yLeft, 0, 1, 1);
    plot->setAxisMaxMinor(QwtPlot::yLeft, 1);
    plot->setAxisScale(QwtPlot::yLeft, -1, 1, 1);

【讨论】:

    【解决方案2】:

    1) 你应该有一些 QwtPlot 对象。我假设您要绘制 xBottom 和 yLeft 轴。

    QwtPlot *plot=new QwtPlot(this);
    //following 4 lines may not be required because
    //QwtPlot defaults are to show xBottom and yLeft axes
    //and you use autoscaling for these axes
    plot->enableAxis(QwtPlot::xBottom);
    plot->enableAxis(QwtPlot::yLeft);
    plot->setAxisAutoScale(QwtPlot::xBottom,true);
    plot->setAxisAutoScale(QwtPlot::yLeft,true);
    

    如果您使用 QtDesigner 和 QwtPlot 小部件,您已经拥有它。您可以使用 ui->plot

    访问它

    2) 你应该有

    QwtPlotCurve * curve = new QwtPlotCurve();
    //.... attach some data to curve
    curve->attach(plot);
    

    3) 可能你想调用 replot

    plot->replot();
    

    【讨论】:

    • 别忘了使用 setData 或 setSamples 用数据填充 QwtPlotCurve
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-17
    • 1970-01-01
    相关资源
    最近更新 更多