PDA

View Full Version : Problem with twitching on axis-ends



ghm
29th September 2011, 08:07
Hi.

I have a problem with twitching in my plot. This twitching comes when the y-, or x-axis is swapping between having a value label at the end or having a tick at the end.

It's best demonstrated by these two screens:
69186919
If you test with the oscilloscope example, and adjust the displayed seconds, back and forth, you will see what I mean by twitching.

This is a bit annoying, especially when having live values thats going up and down.

I have based my widget on the refreshtest example, and managed to work around the problem by setting:


canvas()->setFrameStyle(QFrame::Box | QFrame::Plain );
canvas()->setLineWidth(5);

But this adds a black border around the canvas, and I haven't figured out a way to make that border transparent, or inherit color from application.

If someone have a suggestion on how to workaround this, please let me know.

Gerhard

Uwe
29th September 2011, 10:58
What about setting a margin between the end of the scales and the canvas border: see QwtPlotLayout::setCanvasMargin().

The margin should be larger than half of the width of your tick labels. You could rotate the tick labels, so that you only need half of the font height - or something in between like in the cpuplot example.

Uwe

ghm
29th September 2011, 14:45
Thank you for your reply Uwe.

I managed to solve it by setting plotLayout()->setAlignCanvasToScales(false); for the vertical twitching.

But I also have the problem of twitching horizontally. Whenever a major tick on the y-axis appear that has a number of characters which is greater than the rest. For example you have a range from 0-2, and when the curve goes down to -1, you have one additional character, "-" and "1".

Example:


Y-axis
---
|2|
---
|1|
---
|0|
----
|-1|
----



Is there a way to set a fixed size for the label on the major tick? For instance setting it to 7 characters if you know your y-values ranges from -999999 to 9999999.

Example of wanted behaviour:


Y-axis
------
| 2|
------
| 1|
------
| 0|
------
| -1|
------



Your help is greatly appreciated.

Gerhard

Uwe
29th September 2011, 15:07
This is one of the FAQs: grep for setMinimumExtent.

Also check the event_filter example.

Uwe

ghm
30th September 2011, 14:00
That did the trick.

Thank you Uwe, you've been very helpfull!

Gerhard