Object Data Members

34 views
Skip to first unread message

albu...@gmail.com

unread,
Jun 24, 2021, 12:40:46 PM6/24/21
to pyqtgraph
Been using pyqtgraph for some time. Very happy and impressed.

An important question I have had for some time is:

Is it possible to get access the data held in the graphic objects?

For example.. I can create a line item. I can plot and I can rotate it and translate it with pyqtgraph methods.
If it translate it how do I know where the new end points are? The plotting engine must know otherwise it couldn't work.

I understand it is a fast plotting library. But surely the underlying data would be of extreme value for analysis?

I have just used the isolineItem to find the contour of a laser spot. The visual feedback is helpful. Though I don't know how to get the array of data to proceed with things like finding the center.

I seem to be missing something here....?

Cheers
Alex

Patrick

unread,
Jun 24, 2021, 10:37:59 PM6/24/21
to pyqtgraph
Hi,

The "missing" piece is to remember that pyqtgraph leans heavily on the Qt GraphicsView framework. The scale, translations, rotations of the raw data points are handled by the GraphicsItem transforms, which are really just affine transforms performed by the rendering engine.

You can fetch the raw data from, say, a PlotItem with getData(), but I think you'd need to apply your own affine transforms to the coordinates (you can retrieve the transform matrix with transform() though).

As an aside, I have recently profiled laser spots using OpenCV, visualised with a pyqtgraph UI. It works quite well and can do it in realtime at decent frame rates. It's part of a larger project which is still in early stages of development, but the OpenCV parts might be work looking at, found in the _do_fit() method of this file: https://gitlab.com/ptapping/trspectrometer/-/blob/develop/trspectrometer/plugins/aligncam/alignmentpanel.py

Patrick

Ognyan Moore

unread,
Jun 24, 2021, 11:04:27 PM6/24/21
to pyqt...@googlegroups.com
Hi Alex,

PyQtGraph uses multiple coordinate systems, the view coordinates (used in the ViewBox), the scene coordinate systems (mostly used in the GraphicsScene), the global coordinate system... it can get confusing fast!  Generally speaking, if you want the values that are being plotted, you want to use the .getData() method as Patrick said (oddly enough, it's not in the documentation, huh, should probably change that).  

If you want the values being plotted, you can go one level further and access the QPainterPath objects (in the case of line plots) by calling .getPath() and you can use various methods there.  I wouldn't interact with the QPainterPath object unless there was something very specific you were looking for.

I'm not sure what would happen if you plotted a line, applied a QTransform() to it, and then called .getData().

If you could share an example with what values you were looking for, and the code to set it up, I can take a look.  Generally speaking, when trying to create simple examples, I recommend people start working from one of the examples.

Ogi

--
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/4461c61a-c932-4b62-b842-aadb25a3d30en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages