int margin = 30;
plot
->plotLayout
()->setCanvasMargin
( margin,
QwtPlot::yLeft );
plot
->plotLayout
()->setCanvasMargin
( margin,
QwtPlot::yRight );
int margin = 30;
plot->plotLayout()->setCanvasMargin( margin, QwtPlot::yLeft );
plot->plotLayout()->setCanvasMargin( margin, QwtPlot::yRight );
To copy to clipboard, switch view to plain text mode
helped the x-axis to be aligned when the label is on the border of the canvas.
I would like to the set the legend of the other plots enabled and set the legend of the first plot as RightLegend.
I set an invisible yRight-axis
plot
->enableAxis
(QwtPlot::yRight,
true);
plot
->setAxisMaxMajor
(QwtPlot::yRight,
0);
plot
->setAxisMaxMinor
(QwtPlot::yRight,
0);
plot
->setAxisScale
(QwtPlot::yRight,
0,
0);
plot->enableAxis(QwtPlot::yRight, true);
plot->axisScaleDraw(QwtPlot::yRight)->enableComponent( QwtScaleDraw::Backbone, false );
plot->axisScaleDraw(QwtPlot::yRight)->enableComponent( QwtScaleDraw::Labels, false );
plot->axisScaleDraw(QwtPlot::yRight)->enableComponent( QwtScaleDraw::Ticks, false );
plot->setAxisMaxMajor(QwtPlot::yRight, 0);
plot->setAxisMaxMinor(QwtPlot::yRight, 0);
plot->setAxisScale(QwtPlot::yRight, 0,0);
To copy to clipboard, switch view to plain text mode
and tried to align the axis with following code:
const QList<QwtPlot *> Plots = this->findChildren<QwtPlot *>();
double maxExtent = 0;
sd->setMinimumExtent( 0.0 );
const double legendwidth = p->plotLayout()->legendRect().width();
const double extent = sd->extent( scaleWidget->font() ) + legendwidth;
if ( extent > maxExtent )
maxExtent = extent;
}
double extent;
if ( p->objectName() == "main_plot") //object name of the first plot
extent = maxExtent - p->plotLayout()->legendRect().width();
else
extent = maxExtent;
scaleWidget->scaleDraw()->setMinimumExtent( extent );
}
const QList<QwtPlot *> Plots = this->findChildren<QwtPlot *>();
double maxExtent = 0;
foreach( QwtPlot *p, Plots ){
QwtScaleWidget *scaleWidget = p->axisWidget( QwtPlot::yRight );
QwtScaleDraw *sd = scaleWidget->scaleDraw();
sd->setMinimumExtent( 0.0 );
const double legendwidth = p->plotLayout()->legendRect().width();
const double extent = sd->extent( scaleWidget->font() ) + legendwidth;
if ( extent > maxExtent )
maxExtent = extent;
}
double extent;
foreach( QwtPlot *p, Plots ){
QwtScaleWidget *scaleWidget = p->axisWidget( QwtPlot::yRight );
if ( p->objectName() == "main_plot") //object name of the first plot
extent = maxExtent - p->plotLayout()->legendRect().width();
else
extent = maxExtent;
scaleWidget->scaleDraw()->setMinimumExtent( extent );
}
To copy to clipboard, switch view to plain text mode
But this didnt change anything.
I still want to align axis when there are different sizes of labels on y-Left and the plots height to be minimum.
GraphEx0.jpgGraphEx.jpg
Bookmarks