titanius
2nd October 2013, 20:19
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).
9663
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)
//contentsmagin reduces a pixel line or two but doesnot totally remove everything
ui->widget->canvas()->setContentsMargins(0,0,0,0);
QwtPlotBarChart* device_cri_bar_plot = new QwtPlotBarChart("Device");
device_cri_bar_plot->attach(ui->widget);
// removes the side (left & right) portions and the axes
ui->widget->setAxisMaxMinor(QwtPlot::yLeft,0);
ui->widget->setAxisMaxMajor(QwtPlot::xBottom,0);
ui->widget->setAxisMaxMinor(QwtPlot::xBottom,0);
ui->widget->setAxisAutoScale(QwtPlot::yLeft,true);
ui->widget->setAxisAutoScale(QwtPlot::xBottom,false);
ui->widget->setAxisScale(QwtPlot::yLeft,0,1);
ui->widget->setAxisScale(QwtPlot::xBottom,-0.25,0.25);
ui->widget->axisWidget( QwtPlot::yLeft )->setMargin( 0 );
ui->widget->axisWidget( QwtPlot::xBottom )->setMargin( 0 );
ui->widget->axisWidget( QwtPlot::xTop )->setMargin( 0 );
ui->widget->enableAxis(QwtPlot::xBottom, false);
ui->widget->setCanvasBackground(* new QBrush(Qt::black));
//plot a green bar
QwtColumnSymbol *ptr_to_bar_in_barchart = new QwtColumnSymbol( QwtColumnSymbol::Box );
ptr_to_bar_in_barchart->setLineWidth( 0 );
ptr_to_bar_in_barchart->setFrameStyle( QwtColumnSymbol::NoFrame );
QColor barColor( 0,150,0 );
QVector<QPointF> barpoints;
barpoints<< QPointF(0,1) ;
ptr_to_bar_in_barchart->setPalette( barColor );
device_cri_bar_plot->setSymbol(ptr_to_bar_in_barchart);
device_cri_bar_plot->setSamples(barpoints);
any help would be most helpful.
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).
9663
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)
//contentsmagin reduces a pixel line or two but doesnot totally remove everything
ui->widget->canvas()->setContentsMargins(0,0,0,0);
QwtPlotBarChart* device_cri_bar_plot = new QwtPlotBarChart("Device");
device_cri_bar_plot->attach(ui->widget);
// removes the side (left & right) portions and the axes
ui->widget->setAxisMaxMinor(QwtPlot::yLeft,0);
ui->widget->setAxisMaxMajor(QwtPlot::xBottom,0);
ui->widget->setAxisMaxMinor(QwtPlot::xBottom,0);
ui->widget->setAxisAutoScale(QwtPlot::yLeft,true);
ui->widget->setAxisAutoScale(QwtPlot::xBottom,false);
ui->widget->setAxisScale(QwtPlot::yLeft,0,1);
ui->widget->setAxisScale(QwtPlot::xBottom,-0.25,0.25);
ui->widget->axisWidget( QwtPlot::yLeft )->setMargin( 0 );
ui->widget->axisWidget( QwtPlot::xBottom )->setMargin( 0 );
ui->widget->axisWidget( QwtPlot::xTop )->setMargin( 0 );
ui->widget->enableAxis(QwtPlot::xBottom, false);
ui->widget->setCanvasBackground(* new QBrush(Qt::black));
//plot a green bar
QwtColumnSymbol *ptr_to_bar_in_barchart = new QwtColumnSymbol( QwtColumnSymbol::Box );
ptr_to_bar_in_barchart->setLineWidth( 0 );
ptr_to_bar_in_barchart->setFrameStyle( QwtColumnSymbol::NoFrame );
QColor barColor( 0,150,0 );
QVector<QPointF> barpoints;
barpoints<< QPointF(0,1) ;
ptr_to_bar_in_barchart->setPalette( barColor );
device_cri_bar_plot->setSymbol(ptr_to_bar_in_barchart);
device_cri_bar_plot->setSamples(barpoints);
any help would be most helpful.