I have been searching the forums for the past week on how to do this, so please excuse me if this question has been answered.

I have a QwtPlotSpectrogram attached to a QwtPlot, and I would like to scale the plot so that it spans the entire canvas. I would also like to arbitrarily set the axes regardless of how the data is on-screen. The following code sets up the scaling so that the plot spans the canvas. plot_2d is the QwtPlot widget.

Qt Code:
  1. // This is a hack to properly scale the plot. By default, the plot
  2. // autoscales to values larger than the extent of the data, e.g. an axis
  3. // with value 128 extends to 140, and an axis with value 16384 extends
  4. // to 20000.
  5. const unsigned x_length = data.size1();
  6. const unsigned y_length = data.size2();
  7. plot_2d->setAxisScale(QwtPlot::xBottom, 0, x_length - 1);
  8. plot_2d->setAxisScale(QwtPlot::yLeft, 0, y_length - 1);
  9. // Refresh the axes with the new scale values
  10. plot_2d->updateAxes();
  11. // Call replot the Qwt widget ("owner" of QwtPlotSpectrogram widget)
  12. plot_2d->replot();
To copy to clipboard, switch view to plain text mode 

I have been wholly unsuccessful in setting the intervals for the axes. Most of the things which I have tried have not affected the rendering, and the few which have done something have changed the plot as well. For instance, calling the following code inverts the plot and axis.

Qt Code:
  1. plot_2d->axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Inverted);
To copy to clipboard, switch view to plain text mode 

Is there a way to change the axis interval, for instance, to [-1234.5, 12.345], without changing how the plot is rendered itself? Thank you.