Thanks for reading.

I am trying to plot a bar chart and i am not able to totally remove space (at the top and bottom) in the canvas, in a way that only the bar gets shown (when the value is maximum).

qwtplot_space.png

How do i remove the black portions at the top and bottom of the canvas?


My code as follows:

I promoted a QWidget to QwtPlot (ui->widget)

Qt Code:
  1. //contentsmagin reduces a pixel line or two but doesnot totally remove everything
  2. ui->widget->canvas()->setContentsMargins(0,0,0,0);
  3.  
  4. QwtPlotBarChart* device_cri_bar_plot = new QwtPlotBarChart("Device");
  5. device_cri_bar_plot->attach(ui->widget);
  6.  
  7. // removes the side (left & right) portions and the axes
  8. ui->widget->setAxisMaxMinor(QwtPlot::yLeft,0);
  9. ui->widget->setAxisMaxMajor(QwtPlot::xBottom,0);
  10. ui->widget->setAxisMaxMinor(QwtPlot::xBottom,0);
  11. ui->widget->setAxisAutoScale(QwtPlot::yLeft,true);
  12. ui->widget->setAxisAutoScale(QwtPlot::xBottom,false);
  13. ui->widget->setAxisScale(QwtPlot::yLeft,0,1);
  14. ui->widget->setAxisScale(QwtPlot::xBottom,-0.25,0.25);
  15. ui->widget->axisWidget( QwtPlot::yLeft )->setMargin( 0 );
  16. ui->widget->axisWidget( QwtPlot::xBottom )->setMargin( 0 );
  17. ui->widget->axisWidget( QwtPlot::xTop )->setMargin( 0 );
  18. ui->widget->enableAxis(QwtPlot::xBottom, false);
  19.  
  20.  
  21. ui->widget->setCanvasBackground(* new QBrush(Qt::black));
  22.  
  23.  
  24. //plot a green bar
  25. QwtColumnSymbol *ptr_to_bar_in_barchart = new QwtColumnSymbol( QwtColumnSymbol::Box );
  26. ptr_to_bar_in_barchart->setLineWidth( 0 );
  27. ptr_to_bar_in_barchart->setFrameStyle( QwtColumnSymbol::NoFrame );
  28. QColor barColor( 0,150,0 );
  29. QVector<QPointF> barpoints;
  30. barpoints<< QPointF(0,1) ;
  31. ptr_to_bar_in_barchart->setPalette( barColor );
  32. device_cri_bar_plot->setSymbol(ptr_to_bar_in_barchart);
  33. device_cri_bar_plot->setSamples(barpoints);
To copy to clipboard, switch view to plain text mode 


any help would be most helpful.