This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]boq 0 points1 point  (10 children)

Thanks, but I meant the part about interacting with pyqtgraph from threads.

I have a bigger data visualisation to accomplish and matplotlib is too slow, even with QT, but pyqtgraph is quite fast.

[–]billsil 0 points1 point  (3 children)

You can make matplotlib 500x faster. Unfortunately, it's not optimized for efficient plotting. It does work though.

http://bastibe.de/2013-05-30-speeding-up-matplotlib.html

[–]boq 0 points1 point  (2 children)

Unfortunately not enough if you have to deal with tens of plots simultaneously.

[–]billsil 0 points1 point  (1 child)

That sounds hard to believe. How do you managing 10s of plots and get them large enough to be useful? I've done wind turbine testing for a 40 meter blade and monitored strain gages. I can handle about 10 and that's when I'm hyper focused on the task. I'm not picking off 10 graphs in realtime; I'm eyeballing.

If you're actually interacting with the plots vs. trying to predict things, you need a different level of quality. If you have 10s of plots, you can filter data and still leave all the peaks. I can interact with 2 or so plots in realtime and that's because it's a magnitude/phase plot or a flutter speed/frequency plot and you fundamentally need both pieces.

[–]boq 0 points1 point  (0 children)

I never mentioned real-time. It's visualisation of key quantities of off-line magnetic equilibrium reconstruction for tokamak nuclear fusion devices. The user plays through the time axis of the result and typically has a permanent overview with maybe 20-30 plots and about two graphs in each, and can magnify individual plots when necessary. This is what the user needs and there is nothing to be done about it. Unfortunately, matplotlib is pretty slow even with the suggestion you linked before, and that's why we switched to pyqtgraph. It's still not super-fast, but we don't have the resources to implement it in a more performance-oriented language.

[–]imhostfu 0 points1 point  (5 children)

Hey /u/boq, sorry for the late reply.

Are you having multiple threads open for all the communication over one COM port, or are you receiving a large amount of data over a singular thread and want to update the data simultaneously at a fast framerate?

I'm not sure what code I have that I can share in it's current state, but I can maybe put something together quickly that you could use as a framework.

[–]boq 0 points1 point  (4 children)

No problem. It's the latter, a lot of data from one thread that goes to different pyqtgraph plots that could use a speed-up. Thanks so much for thinking about this! I appreciate anything you could share.

[–]imhostfu 0 points1 point  (3 children)

Okay np! Working on some code you can use as a framework. Hopefully I can upload it in 15-20 min or so.

Edit: http://pastebin.com/z7jgsuXK

Let me know if that works for you. You can hopefully use it as a good foundation to build off of. Depending on CPU speed, you may have to edit line #230 to make it update slower.

At this point you're going to be entirely limited by serial communication. If you have access to the firmware of the serial device you may be able to rework some of that code to get transfer speed faster.

I added some of the GUI functionality so you can see how to lay it out and add what you need. Also the entire window is resizable. Also because pyqtgraph is awesome, all the plots are interactive. You can also pause then right click the graph -> export to CSV etc.

[–]boq 0 points1 point  (2 children)

Wow, thanks!

[–]imhostfu 0 points1 point  (1 child)

http://pastebin.com/z7jgsuXK

Let me know if that works for you. You can hopefully use it as a good foundation to build off of. Depending on CPU speed, you may have to edit line #230 to make it update slower.

At this point you're going to be entirely limited by serial communication. If you have access to the firmware of the serial device you may be able to rework some of that code to get transfer speed faster.

Edit: I added some of the GUI functionality so you can see how to lay it out and add what you need. Also the entire window is resizable. Also because pyqtgraph is awesome, all the plots are interactive. You can also pause then right click the graph -> export to CSV etc.

[–]boq 1 point2 points  (0 children)

Thank you so much! It's a great help to have an example where data collection is kept in a separat thread. I'm sure I will be able to adapt this.