Re: how to let autoscale leave a border around the data
Brought to you by:
rathmann
From: Matthias P. <mat...@gm...> - 2010-08-31 08:24:00
|
Uwe Rathmann schrieb: >> which is correct, since the data in y is -pi:pi. However the printed plot >> is from -pi:pi instead of -3.45:3.45. >> > > Did you implement the following sequence: > > a) assigning the data to your curve ( implicitly changing the bounding rect ) > b) re-enable autoscaling ( might be disabled from manual zooming ) > c) replot > d) reinitialize your zoomer from the changed axes scales. > > If c) doesn't give you the scale you expect check the options of your scale > engines. > > I do set manual scales in this example. The scales in y direction are -pi:pi. this is handled in the OnZoomed() function: /*! * handle zoom events, especially reset zoom-base * if back to initial zoom state */ void QPlotExtZoomer::OnZoomed() { static int previousIndex = 0; int index = this->zoomRectIndex(); // debugZoomerStack(); // save startup scales if ((index == 0) && (previousIndex == 0)) { // set or unset autoscale depeding on plot settings d->plotManualScaleX.enabled = !d->plot->axisAutoScale(QwtPlot::xBottom); d->plotManualScaleY.enabled = !d->plot->axisAutoScale(QwtPlot::yLeft); setZoomBase(false); // no replot } // only reset zoombase and replot if coming from // zoomed state and state is at the initual size if ((index == 0) && (previousIndex > 0)) { if (!d->plotManualScaleX.enabled) { d->plot->setAxisAutoScale(QwtPlot::xBottom); } else { d->plot->setAxisScale(QwtPlot::xBottom, d->plotManualScaleX.min, d->plotManualScaleX.max); } if (!d->plotManualScaleY.enabled) { d->plot->setAxisAutoScale(QwtPlot::yLeft); d->plot->setAxisAutoScale(QwtPlot::yRight); } else { d->plot->setAxisScale(QwtPlot::yLeft, d->plotManualScaleY.min, d->plotManualScaleY.max); } setZoomBase(true); // replot } previousIndex = index; // debugZoomerStack(); } So how would I ensure that margins are added although I set up a manual scale (here this is only in y direction). Or do I have to change the scale values myself? > Uwe > > PS: the bounding rect of all plot items, that want to participate in > autoscaling ( QwtPlotItem::AutoScale ) is used to calculate the x1, x2 > parameters for QwtScaleEngine::autoScale(). If your code is o.k. you should > find your margins there. > I do not understand where I should find theQwtPlotItem class in my example. I use QwtPlot, QwtPlotCurve and QwtPlotZoomer as classes. Matthias |