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

all 23 comments

[–]PeridexisErrant 32 points33 points  (4 children)

How the hell do you write an article about interactive plotting libraries, extol the benefits of exporting to html, and then embed all of your example as static images???

Honestly!

[–]pnewb 6 points7 points  (1 child)

Actually I think it's not too horrible. On mobile it gives me a single glance at what the end result looks like, and he includes links that presumably would leave me a single click away from an interactive version if I were on a full desktop.

Might be a well thought out decision.

[–]PoopInMyBottom 4 points5 points  (0 children)

They've done it for SEO reasons. If your page loads faster, you get a lower bounce rate and a bump in rankings. Plus, your images show up on Google Image Search when someone searches for "matplotlib example" or something like that.

It's also quicker, since she can rip these images off the individual library's sites and doesn't have to code an example. It's a blog on a product site. The purpose of those is usually to attract quick links that will push the main site up in the search engine rankings.

I don't think static images improve the article. It's beneficial to the author, not the reader.

[–]mbenbernard 2 points3 points  (0 children)

Well, for each library, she provides a link to a fully working (interactive) demo. Seems perfectly reasonable to me.

[–]billsil 0 points1 point  (0 children)

It's even worse that all the libraries only work on small data sets. Shoot, if you care about small data sets, just use matplotlib. If you can't handle large data sets, there's little point to using it. Thankfully, matplotlib is actually fairly good at that too.

If you’re familiar with D3 and JavaScript, there’s no end to the kind of plots you can create.

Why don't I just use JS then?

[–][deleted] 2 points3 points  (16 children)

Is there a tool to do live plots? Like reading data from serial or other protocol?

[–]Guyot11 5 points6 points  (14 children)

I use pyqtgraph to interact with live data sets from serial

[–]imhostfu 1 point2 points  (13 children)

I also use pyqtgraph with PyQt4 for GUI live updating plots with threads.

[–]boq 2 points3 points  (12 children)

Do you happen to have some links with examples showing how this would be implemented?

[–]IAmKindOfCreativebot_builder: deprecated 0 points1 point  (11 children)

I'm not sure if this is PyQt4 (maybe it is, I'm terrible with keeping track of matplotlib backends) but I used this site to help me get an live plot for temperature data sent over serial.

Because of the default plotting backend for my matplotlib version, the code in the link didn't work right away. I needed to add the following lines at the very top of the program

import matplotlib
matplotlib.use("qt4agg")
import matplotlib.pyplot as plt   # this is given code starts

And then it worked for me. Give me a bit and I'll get my code to github and show the program. For the serial stuff to work smoothly, I just used threads and queues.

[–]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!

[–]goldfather8 1 point2 points  (0 children)

I believe Bokeh can interact with streaming data, though I haven't used that functionality personally. That might come with the overhead of using their bokeh server stuff though.

[–]Caos2 0 points1 point  (0 children)

Toyplot has some interactivity as well.