Plotting data in real time is a very useful task that could be tough, but using the tool KST, I will show how easy it is. The front end look very professional and clean to present your project. KST is a very powerfull and robust solution for plotting live “streaming” data.
Get FREE Credit for your next AirBnb Reservation by opening a new account (even if you already have one!)
Why I chose KST?
- It is free and open source.
- You can control it with the user interface (with the mouse), but it is also fully scriptable with python (under linux).
- It is very powerful. In my project I visualize 22 realtime sensors at 15 Hz and it runs perfectly.
- it is cross-platform. I started using it on windows, but later move to Ubuntu and then RaspberryPi.
1.First download KST. It is available to all the platforms: Windows, Mac and linux. Follow the instructions from the website to complete the installation in your OS.
2. Execute the program. If you are using Windows, just unzip and go to folder /bin and open the executable file “kst2.exe”.
If you are using linux, you have to call the following command to open the GUI:
Also is possible to call kst from a python script. For that use:
subprocess.Popen[("kst2")] #open the real time plotter
If you want to open a saved kst configuration file, which have to be in the root folder:
subprocess.Popen[("kst2", "myKSTfile.kst")] #open the real time plotter
3. Open the data wizard and go through. I will explain a standard configuration with these pictures.
4. First of all select the source file. This is usually a csv or a txt file. Then choose the time interval: “change detection” if you are working with local data. If you want to reproduce a saved file, which is not going to be updated, just select “no update“. Don´t forget to change the ASCII file configuration.
5. ASCII configuration. Here you modify the parameters to explain the program how to interpret the data from the file. This configuration depend on your file. Check the parameters I marked in red on the picture.
6. Select your data you want to plot. If your file has a header (normally on the first row) with the field names and you have selected previously “Read field names from line“, now you should see the names (like in the following picture). If not, you will see “column 1″, Column 2”, etc… Kst always generates an automatic column called INDEX, which is the numbers 0, 1, 2, 3, 4, 5, 6… useful to use on the x-axis.
Put the columns you want to visualise on the right part and then go to the next step.
7. Data range. Usually, you want to plot real time data, so you wish to see the last X samples available in your csv file. In this case select “count from end” and put range between 200 and 500 depending on the speed you read the data. This can be changed later.
Put on the X-axis the INDEX column, if you don’t have an special column for the x-axis like time.
8. Layout configuration. I would leave this as default and later you can change what you like easily. The only thing I regularly do is removing the legends of each plot. This make a better view. legends only makes sense if you plot more than one curve per graph.
After pressing Finish, some view like this should appears:
Dont forget to save the configuration if you are going to reuse this plot. A *.kst file is generated and you will save many time for the next time. If you are using linux, you can just run the command:
kst2 myKSTfile.kst #open your kst file and start plotting data
How to modify the visualisation?
KST allows to modify it “live”, very easy and with the mouse. There are hundreds of possibilities. Here I will mention some handy tips I consider relevant:
- For example to change the order of the graphs, just drag and drop and you will change the order. Then click on automatic to clean up and leave the layout more tidy.
- To change the Y scale of the axis and set it to a fix range. This is needed because it varies a lot when are set by auto. For this select a graph and pressing the key E (or by double click).
- Remember that if you want to change all the graphs with the same configuration just go to “Edit Multiple” on the top right part and select all.
- To modify the speed of the incoming data (scale the X axis) or how many last data do you visualize. For that click on the “Data Range” icon (on the next picture) and modify the “Range” as shown in the following pictures:
- Press ‘Z’ or right-click over a graph and select “Maximize plot” to see it in full-screen. Later you can press again ‘Z’ and everything will return to the normality.
KST let you modify a lot your visualisation front end. Here I only mentioned a couple of trick I find practical to start using this software.