Reputation: 51
I am using qwt plot curve to draw curve. the x axis and the y axis are not visible, only the curve is visible. How to show the axis with showing some first, last and middle values in the scale interval of the axis
Upvotes: 0
Views: 3606
Reputation: 4742
1) You should have some QwtPlot object. I assume you want to draw xBottom and yLeft axes.
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);
You already have it if you were using QtDesigner and QwtPlot widget with it. You can access it with ui->plot
2) You should have
QwtPlotCurve * curve = new QwtPlotCurve();
//.... attach some data to curve
curve->attach(plot);
3) Probably you want to call replot
plot->replot();
Upvotes: 1
Reputation: 56
I give you a small example:
// 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);
Upvotes: 2