Set the Z value of the grid lines

25 views
Skip to first unread message

JJ

unread,
Jun 19, 2024, 3:53:54 AMJun 19
to pyqtgraph
I don't like the grid lines being displayed on top of the curves. What's the best way to solve this?

Is it possible to set the Z value of the grid lines in order to change this?

I've tried setting the z value of the curves to 1e6 but this doesn't make any difference.

Patrick

unread,
Jun 19, 2024, 10:09:57 PMJun 19
to pyqtgraph
Hi,

I had a similar problem where ImageItems were drawn above the axis lines and tick marks, which I solved by changing the z value of the axes with
[ plot.getAxis(ax).setZValue(10) for ax in plot.axes ]
I believe that also affects the grid lines. You'll need to play with the value (try -1) to push the axes back in the stack behind the plot lines.

Alternatively, you could probably setZValue(100) on each of your PlotDataItems when you create them to stack them in front of everything else.

Patrick

JJ

unread,
Jun 24, 2024, 3:44:06 AM (14 days ago) Jun 24
to pyqtgraph
This solves the issue. Thanks!

Ognyan Moore

unread,
Jun 24, 2024, 4:00:46 AM (14 days ago) Jun 24
to pyqt...@googlegroups.com
A little more context, for performance reasons a while ago it was decided that grid lines should be drawn (or “painted”) as an extension of AxisItem. This has caused confusion like shown here in the mail list for this very specific issue. Given we have made major performance improvements in the library recently we should probably revisit how bad the performance penalty would be if grid lines were their own thing.

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/8b12bb67-3314-4dc5-901a-99e1c1f38886n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages