3

In Qwt is it possible to change the location of both axis' from bottom left (default position) to the middle of the QwtPlot? (intersection of both axis should be at the center of the plot). I yet to to find a piece of code that does that.

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();
Samer
  • 1,923
  • 3
  • 34
  • 54

1 Answers1

3

Try this:

    QwtPlotScaleItem *it = new QwtPlotScaleItem(QwtScaleDraw::RightScale ,0.0);
    it->attach(ui->qwtPlot);

    QwtPlotScaleItem *it1 = new QwtPlotScaleItem(QwtScaleDraw::BottomScale ,0.0);
    it1->attach(ui->qwtPlot);

If you want hide your major axis, use this:

ui->qwtPlot->enableAxis(QwtPlot::yLeft,false);

Result:

enter image description here

Jablonski
  • 18,083
  • 2
  • 46
  • 47
  • Thank you for your answer, please see my code above...I still can see only the two axis on bottom and left! – Samer Oct 02 '14 at 18:11
  • @Samer I don't know what is wrong with your code, documentation said, that with enableAxis you can disable this axis, on my computer (in the graphicsView) thre is no any axis and QwtPlotScaleItem works properly. Sorry. – Jablonski Oct 02 '14 at 18:29
  • 1
    finally, i got to work it turns out that the center position for me is (500, 500) not (0,0). Thanks anyways – Samer Oct 02 '14 at 19:02
  • how can I add an AxisTitle to a `QwtPlotScaleItem`? – lena Oct 13 '16 at 08:16