PDA

View Full Version : How to force plot grid to follow top axis?



Sintegrial
11th November 2015, 16:28
Hi Everybody,

is there a possibility to snap the grid to the top axis?
I.e. so that vertical lines of the grid will follow minors and major ticks of the axis.
By default, it seems to be always snapped to the bottom one.

Uwe
11th November 2015, 16:47
grid->setXAxis( QwtPlot::xTop );

HTH,
Uwe

Sintegrial
11th November 2015, 17:01
Thank you a lot Uwe!

That was really stupid question, I should have look at QwtPlotItem interface of course :(

Could you please tell is it also possible to get an axis with a non-regular scale?
I.e. when the ticks are defined in a complete arbitrary way, say, by a table or so on.
Playing around with QwtTransform did not bring a lot, actually.
Or there is another approach to achieve this?

btw, Qwt is great ;)

Uwe
11th November 2015, 18:22
Could you please tell is it also possible to get an axis with a non-regular scale?
When there is no rule use QwtPlot::setAxisScaleDiv(), otherwise the rule has to be implemented somehow using QwtScaleEngine/QwtTransform.

Uwe

Sintegrial
12th November 2015, 16:46
I've tried to use setAxisScaleDiv() as a very simple test, like that:



QwtScaleDiv scaleDiv(0.0, samplesCount);

m_plotPtr->setAxisScaleDiv(QwtPlot::xBottom, scaleDiv);
m_plotPtr->enableAxis(QwtPlot::xBottom, true);


but unfortunately the bottom axis disappears after these lines :(

Sintegrial
13th November 2015, 10:13
Ok, found the reason: when there are no ticks set, the scala will not be drawn.
Thank you again Uwe!