We recently had a typical project that needed an easy way of offline data analysis. The customer’s requirements were to store all the data + a screenshot, if the screenshot looks right, we’ll never look at the data again. The only problem with that was that the screenshot looked like this:
So we wondered how we could give the user something similar, but more interactive and we immediately thought of plot.ly which is widely used in data sciences to visualize datasets in a neat and informative way. Labplot.ly was born.
Put on your own mask, before helping others
In v0.2 of LabPlot.ly, we implemented what we needed ourselves: A way to visualize graphs in a website that can be saved or just displayed. We reckon that because of the way LabVIEW is most commonly used this will cover a big chunk of applications already.
The functions call a python script that generates the HTML file. In LabVIEW, the LabPlot.ly functions do not need initialization and can be dropped anywhere on the block diagram. Let’s take a look at
Plots a simple graph from 1D data over its index. Not too spectacular, but let’s look at some of the features that remain the same throughout the toolkit:
graphSettings – lets you change the appearance of your graph, whether or not you’d like the points to be marked, whether you want dashed lines or not and how wide you want your lines
File Path – Path where you’d like the HTML file to be stored. If left empty, it just opens a browser window with the data. You can interact with it and save screenshots, but as soon as you close it, it is gone.
Note that in the HTML, you can mouse over points to display data, zoom, pan and even download as a png right on the page.
Plots the data points over an x array. Just pass a 2D array to the function to display it.
In the example, you’ll find an execution time indicator, that will display a value of a couple of seconds. It takes the toolkit a moment to put together the HTML file, especially with larger datasets, so we included both synchronous and asynchronous calls to not hold up your program.
The 2D Multi-function allows you to have multiple plots within the same graph. There are settings for Reduction and graphSettings for each individual graph that must be passed in, meaning the array length of graphSettings, Reduction and Data must match for all plots to be displayed.
One parameter that hasn’t been mentioned yet is the Reduction. During development, we noticed that the files become large and slow to open in the browser for datasets larger than 200,000 points. We, therefore, implemented a function to reduce the datasets to the relevant points. The lttb functions do just that and allow you an integrated way of reducing the dataset while conserving the vital features of the graph.
In the following graph, you can see the effect of that. The blue markers show the profile consisting of 9 points, while the rest show extrapolated datasets of 200k points, but reduced to 2000, 9, 10, 20, 30 points respectively. You can see that it is possible to get a good approximation with as little as 3 times the number of points in the profile. It’s worth pointing out that 9 points almost gets it right, but misses the second to last peak completely, while 10 and 20 are even worse.
Also, if you have a long dataset, the distribution will be more uniform, meaning that even though you could draw the graph from the ugly example at the top of this post in 9 points, It will probably end up omitting the initial peak.
What’s coming next?
We have grouped the future features into the following groups:
Easy to implement – Features that don’t deviate too much from the current feature set and are easy to implement. In this category are Bar Plots, Polar plots, Pie Charts, Histograms and 2D Histograms but also some more design Elements like plot titles and background settings. A way to publish the data to a plot.ly dashboard has also already been implemented and can be made available if need be. We also plan to expose the lttb data reduction function as it might come in handy in LabVIEW.
Desirable – Ideally, we’d like to add some more advanced options like allowing the user to build a page layout or map overlays. These features take a bit more time.
User requested – More than any of the above, we’re interested in what the end-user wants, so why don’t you tell us, which features you’d like to see? You can do so either on the Gitlab Page, the vipm community page or right here in the comments. You can head on over to the plot.ly/gallery and get inspired. But don’t stop there, let us know what data you have and how you’d like to visualize it.