在Qwt中,可以改变两个轴的位置。从左下角(默认位置)到QwtPlot的中间? (两个轴的交点应位于图的中心)。我还没有找到一段能够做到这一点的代码。
myPlot = new QwtPlot(this->ui.graphicsView_outter);
QSize plotSize = ui.graphicsView_outter->size();
myPlot->resize(plotSize);
myPlot->setTitle("Calibration");
myPlot->setAxisTitle(QwtPlot::xBottom, "X");
myPlot->setAxisTitle(QwtPlot::yLeft, "Y");
myPlot->enableAxis(QwtPlot::yLeft,false);
myPlot->enableAxis(QwtPlot::xBottom,false);
QwtPlotScaleItem *it = new QwtPlotScaleItem(QwtScaleDraw::RightScale ,0.0);
it->attach(myPlot);
QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0);
it1->attach(myPlot);
myPlot->replot();
答案 0 :(得分:2)
试试这个:
QwtPlotScaleItem *it = new QwtPlotScaleItem(QwtScaleDraw::RightScale ,0.0);
it->attach(ui->qwtPlot);
QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0);
it1->attach(ui->qwtPlot);
如果要隐藏主轴,请使用:
ui->qwtPlot->enableAxis(QwtPlot::yLeft,false);
结果: