QwtPlot zooming logarithmic scale



  • zoscHello,

    i have a QwtPlot with a logarithmic scale on y and time scale on x. That was not the problem, but zooming into the graph.
    I have three unwanted effects, but don't know how to fix:

    1. when use wheel mouse to zoom in i can see on my y-axes only 1000 no other values.
    2. when i zoom out my y-axes goes down to 1E-100 ?
    3. when i use ctrl+LeftMouse to open the RubberBandPan to zoom from 400 to 1000 mbar, i see a lot of values of the y-axes
      from 440 to 1000 every 20 mbar.
    4. when i zoom into 1e-5 to 1e-6 dosen't work, i see y-axes range from 0,01 to 1e-100 ?

    Thx for you help

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

  • Moderators

    @HappyCoder

    Out of personal experience I recommend also to ask your question on QWT mailing list
    AFAIK QWT is still independent and only based on Qt libs. Uwe has been monitoring this forum in the past, but answers are potentially faster through QWT mailing list.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.