PlotItem Item Z-order

1,089 views
Skip to first unread message

Nick

unread,
Feb 7, 2014, 12:41:19 PM2/7/14
to pyqt...@googlegroups.com
Hello,

Im wondering if it is possible to modify the "Z-order" of a line after a number of plot calls are made?

For example, I have an interactive application where the user can plot a number of data channels as follows:

pltwidgetlist[pltwidgetIndex].plot(time1,data1, name =channel1, pen =colour1, clickable=True)
pltwidgetlist[pltwidgetIndex].plot(time2,data2, name =channel2, pen =colour2, clickable=True)
pltwidgetlist[pltwidgetIndex].plot(time3,data3, name =channel3, pen =colour3, clickable=True)

Newer plots always lie ontop of the previous and sometimes this can be a pain when the newer data obscures the old. It would be useful if there is a way to change the order of each plot after they are plotted. E.g. move oldest one to front, or move the clicked on curve to the front.

It seems that the code in PlotItem.py would handle this, however I cant see a way to re-order and re-draw...

Thanks,
Nick

Luke Campagnola

unread,
Feb 7, 2014, 3:59:19 PM2/7/14
to pyqt...@googlegroups.com
On Fri, Feb 7, 2014 at 12:41 PM, Nick <nerdin...@gmail.com> wrote:
Im wondering if it is possible to modify the "Z-order" of a line after a number of plot calls are made?

The method you are looking for is buried in the Qt documentation here:

PlotWidget.plot() returns a PlotCurveItem, which is a subclass of QGraphicsItem. So:

    curve = plot_widget.plot(...)
    curve.setZValue(...)

Nick

unread,
Feb 9, 2014, 10:17:04 AM2/9/14
to pyqt...@googlegroups.com
Luke,

Thanks for your quick and informative reply! I've got it working now.
Thanks for a great library!

Nick
Reply all
Reply to author
Forward
0 new messages