bdesham
bdesham

Reputation: 16089

How do I add extra space around the axis labels on a QwtPlot?

I have a QwtPlot subclass that draws labels for the left and bottom axes and I would like to add some extra margins to these labels—specifically, between these labels and the tick marks’ numerical labels. Is there any built-in way to add such padding? (I’m using the QwtPlainTextEngine to render the labels now, so I guess I could create my own subclass that adds extra space, but that would be much lower-level than I’d like.)

Upvotes: 0

Views: 1869

Answers (2)

Uwe
Uwe

Reputation: 725

See QwtAbstractScaleDraw::setSpacing()

Upvotes: 2

alperyazir
alperyazir

Reputation: 213

I had same problem and solved like these methods.

Method 1:

We can give a margin with canvas like this

double margin = 30;
plot->plotLayout()->setCanvasMargin(margin, QwtPlot::yLeft);
plot->plotLayout()->setCanvasMargin(margin, QwtPlot::yRight);

Don't forget #include <qwt_plot_layout.h>

Method 2:

Using axis distance border distance. Here is the example:

double margin = 30;
plot->axisWidget(QwtPlot::xBottom)->setMinBorderDist(margin, margin);

Don't forget #include <qwt_scale_widget.h>

I hope this will be useful.

Upvotes: 1

Related Questions