I subclass QwtPlot and create function to set minValue, maxValue and scaleEngine of the axis. Also I draw axis inside plot canvas. Here is relevant part of the code:
Qt Code:
  1. void GeneralPlot::drawAxisInsideCanvas(){
  2. QwtPlotScaleItem *scaleItemY =
  3. new QwtPlotScaleItem(QwtScaleDraw::RightScale);
  4. scaleItemY->setBorderDistance(0);
  5. scaleItemY->attach(this);
  6. this->enableAxis(QwtPlot::yLeft, false);
  7. this->setAxisScale(this->yLeft,0,1);
  8. this->setAxisMaxMinor(this->yLeft,0);
  9.  
  10. QwtPlotScaleItem *scaleItemX =
  11. scaleItemX->setBorderDistance(0);
  12. scaleItemX->attach(this);
  13. this->enableAxis(QwtPlot::xBottom, false);
  14. this->setAxisScale(this->xBottom,0,100);
  15. this->setAxisMaxMinor(this->xBottom,0);
  16. this->updateAxes();
  17. }
  18.  
  19. void GeneralPlot::setXAxis(double xmin, double xmax, bool linear){
  20. bool xlinear = dynamic_cast<QwtLinearScaleEngine*>(axisScaleEngine(xBottom))!=NULL;
  21. if(xlinear){
  22. setXAxisScale(xmin, xmax);
  23. setXAxisLinear(linear);
  24. }else{
  25. setXAxisLinear(linear);
  26. setXAxisScale(xmin, xmax);
  27. }
  28. this->updateAxes();
  29. }
  30.  
  31. void GeneralPlot::setXAxisScale(double xmin, double xmax){
  32. setAxisScale(this->xBottom, xmin, xmax);
  33. }
  34.  
  35. void GeneralPlot::setXAxisLinear(bool b){
  36. bool xlinear = (dynamic_cast<QwtLinearScaleEngine*>(axisScaleEngine(xBottom))!=NULL);
  37. if(xlinear&&!b){
  38. setAxisScaleEngine(xBottom, new QwtLogScaleEngine());
  39. }
  40. else if(!xlinear&&b){
  41. setAxisScaleEngine(xBottom, new QwtLinearScaleEngine());
  42. }
  43. this->updateAxes();
  44. }
To copy to clipboard, switch view to plain text mode 

GeneralPlot::drawAxisInsideCanvas() function is called in constructor. The problem is that sometimes axis is not updated, however plot canvas is updated. For example if I call :
Qt Code:
  1. plot->setXAxis(1, 100, false) //1 - 100 log scale
  2. plot->replot()
To copy to clipboard, switch view to plain text mode 
everything is fine, but if after that I call
Qt Code:
  1. plot->setXAxis(-100, 100, true) // linear scale
  2. plot->replot()
To copy to clipboard, switch view to plain text mode 
Axis is not updated, however plot with grid is already updated. If I resize plot window then axis updates. Everything works fine if I don't plot axis inside plot canvas (don't call drawAxisInsideCanvas() in constructor) then everything is fine. How shoul I make QwtPlotScaleItem to be updated after plot replot?