QWT图曲线轴线不可见

qwt plot curve axis not visible

本文关键字:曲线 QWT      更新时间:2023-10-16

我使用qwt plot curve来绘制曲线。x轴和y轴不可见,只有曲线可见。如何显示轴显示一些第一,最后和中间值轴的缩放间隔

我给你一个小例子:

   // 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);

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

访问它

你应该有

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

3)可能需要调用replot

plot->replot();