qwt对数坐标轴
qwt吧
全部回复
仅看楼主
level 1
free如星 楼主
新手求助:如何在用qwt绘图时,修改坐标轴为对数坐标
2017年05月15日 09点05分 1
level 3
QwtLogScaleEngine* axesy = new QwtLogScaleEngine();
ui->plot->setTitle("Plot");
ui->plot->setAxisTitle(QwtPlot::yLeft,QString("Pressure [%1]").arg(QString("mbar")));
ui->plot->setAxisTitle(QwtPlot::xBottom,QString("Time [%1]").arg(QString("s")));
ui->plot->setAxisScaleEngine(QwtPlot::yLeft, axesy);
ui->plot->setAxisMaxMajor( QwtPlot::yLeft, 100);
ui->plot->setAxisMaxMinor( QwtPlot::yLeft, 10);
ui->plot->setAxisScale(QwtPlot::yLeft,1e-10,2000);
// Setting Magnifier
QwtPlotMagnifier* zoom_x = new QwtPlotMagnifier(ui->plot->canvas());
QwtPlotMagnifier* zoom_y = new QwtPlotMagnifier(ui->plot->canvas());
// Shift+MouseWheel --> Magnifier x
zoom_x->setWheelModifiers(Qt::ShiftModifier);
zoom_x->setAxisEnabled(QwtPlot::xBottom, true);
zoom_x->setAxisEnabled(QwtPlot::yLeft, false);
// CTRL + MouseWheel --> Magnifier y
zoom_y->setWheelModifiers(Qt::ControlModifier);
zoom_y->setAxisEnabled(QwtPlot::xBottom,false);
zoom_y->setAxisEnabled(QwtPlot::yLeft,true);
// Left Button for panning
QwtPlotPanner* panner = new QwtPlotPanner (ui->plot->canvas());
panner->setMouseButton(Qt::LeftButton);
//QwtPlotZoomer* zoomer = new QwtPlotZoomer( ui->plot->canvas() );
QwtPlotZoomer* zoomer = new QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, ui->plot->canvas() );
zoomer->setRubberBandPen( QColor( Qt::black ) );
zoomer->setTrackerPen( QColor( Qt::red ) );
// CTRL+LeftButton for the zooming
zoomer->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ControlModifier);
// CTRL+RightButton back to full size
zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
QwtPlotGrid *grid = new QwtPlotGrid();
grid->enableY(true);
grid->enableYMin(true);
grid->setMajorPen( Qt::darkGray, 0, Qt::SolidLine );
grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
grid->attach(ui->plot);
QwtLegend* legend = new QwtLegend;
legend->setDefaultItemMode(QwtLegendData::Checkable);
ui->plot->insertLegend(legend,QwtPlot::RightLegend);
2020年04月08日 03点04分 2
1