User avatar
jbeale
Posts: 3893
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

recommend scientific graphing program?

Tue May 04, 2021 7:07 pm

This is not specific to R-Pi of course, but that's what I'm using and I think likely people here have good ideas.
I graph a lot of sensor data as a time series. My usual timestamp is a single number that is Unix epoch (seconds from Jan.1 1970).

I find the "Kst-Plot" program https://kst-plot.kde.org/ very useful. If you set it as the default handler for .csv files, you can just double-click on a CSV file and see the graphs immediately. A particularly good feature for me is that it can interpret Unix epoch seconds as a real time/date on the X axis. On the graph window, you can hover your mouse over any data point and see that point as MM/DD/YY HH:MM:SS, which is handy. However the graph axis formatting is a little awkward. For example, I don't have control (as far as I know) over when the text timestamp starts at the X axis origin. When plotting say 36 hours of data, it seems to choose random starting hours like 23H or 05H but regardless where I start my timestamps, it will not show a graph starting at midnight. That does not affect the data itself, but it's a presentation annoyance if you want things lined up with the start of a day, for example.

I'm not sure Kst-Plot is under much active development since the original author left maybe 6 years ago. Is there any scientific graphing program people like that does this feature well (displaying time/date on a graph, based on epoch time)?
KstExample.png
Kst-Plot output
KstExample.png (111.18 KiB) Viewed 928 times
Last edited by jbeale on Tue May 04, 2021 7:34 pm, edited 1 time in total.

Heater
Posts: 18758
Joined: Tue Jul 17, 2012 3:02 pm

Re: recommend scientific graphing program?

Tue May 04, 2021 7:28 pm

I recently found it's easy to plot almost any kind of data in almost any kind of way with only a few lines of script in the Julia language:
https://www.math.purdue.edu/~allen450/P ... orial.html

There is a discussion about installing Julia on a Pi going on here: https://www.math.purdue.edu/~allen450/P ... orial.html

Otherwise I have always used GNU Plot: https://alvinalexander.com/technology/g ... -examples/
Memory in C++ is a leaky abstraction .

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6561
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: recommend scientific graphing program?

Tue May 04, 2021 8:14 pm

Although, pre-Pi, I've used GNU Plot, most of the time I've used QtiPlot esp. for all those PSU current loading graphs** :)
Trev.
** http://www.cpmspectrepi.uk/raspberry_pi ... plies.html etc.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) but Buster on the P3B+, P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
Gavinmc42
Posts: 6304
Joined: Wed Aug 28, 2013 3:31 am

Re: recommend scientific graphing program?

Tue May 04, 2021 11:28 pm

I recently found it's easy to plot almost any kind of data in almost any kind of way with only a few lines of script in the Julia language:
You got Plots pkg to work?

I use Dygraphs.js on my net connected Pi.
Took a bit of tweaking to save the files in a csv format Dygraphs liked.
I also did daily log files.

I tried almost every plot software around years ago.
None were that good I would use it for everything.
Ended up going baremetal and DIY with Ultibo for standalone apps.
Ultibo based webservers served Dygraphs.js no problem as well :D

Still have no solution for multi day, month, year plots.
For that I have been looking at accelerated 3D software.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 18758
Joined: Tue Jul 17, 2012 3:02 pm

Re: recommend scientific graphing program?

Wed May 05, 2021 4:26 am

Gavinmc42 wrote:
Tue May 04, 2021 11:28 pm
You got Plots pkg to work?
Ah, you caught me out there. I have not actually tried plotting with Julia on a Pi. None of my Pi have a screen.

Is there a problem with it?
Memory in C++ is a leaky abstraction .

User avatar
Gavinmc42
Posts: 6304
Joined: Wed Aug 28, 2013 3:31 am

Re: recommend scientific graphing program?

Wed May 05, 2021 6:30 am

Ah, you caught me out there. I have not actually tried plotting with Julia on a Pi. None of my Pi have a screen.
Is there a problem with it?
Tried with 1.0.3 and 1.6.1, could get a plot and took ages to compile and I have no idea were the "compiled" file ended up.
Still on the steep part of the learning curve with Julia.
I would show you where if I could plot it :lol:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

tpylkko
Posts: 416
Joined: Tue Oct 14, 2014 5:21 pm

Re: recommend scientific graphing program?

Thu May 06, 2021 4:21 am

I have to second the notion that plotting in Julia is very convenient and effecient. Because it is just-in-time compiled, the first time you use your routine is many time slower than after that.

However, on a pi I have not used it. No idea if it works. There was some optizations to the time-to-first-plot in 1.6 iirc

Another widely used option not mentioned yet in this thread is matplotlib in python.

Then, of course, there are very famous plotting packages in R

User avatar
Gavinmc42
Posts: 6304
Joined: Wed Aug 28, 2013 3:31 am

Re: recommend scientific graphing program?

Thu May 06, 2021 5:44 am

Then, of course, there are very famous plotting packages in R
I had forgotten R, pretty sure it just worked years ago.
Tried two IDEs for it, one didn't work.

Worth seeing how fast it is on a Pi4 now.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
jbeale
Posts: 3893
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: recommend scientific graphing program?

Tue Jun 22, 2021 3:45 pm

I recently came across Veusz https://veusz.github.io/ which is a reasonably capable, open-source and cross-platform plotting package. My initial experience is that it mostly does what I want, and I was able to simply install it on Windows, and an Intel-based Linux box. However I have so far been unable to get it running on a Pi (it compiles and installs without error, but a runtime error seems to suggest it expected some earlier version of PyQt5 than what I have). Has anyone got this program running on a Pi?

dbrion06
Posts: 690
Joined: Tue May 28, 2019 11:57 am

Re: recommend scientific graphing program?

Tue Jun 22, 2021 3:48 pm

python3 matplotlib is/was very sarisfying for me

User avatar
scruss
Posts: 4485
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: recommend scientific graphing program?

Tue Jun 22, 2021 9:55 pm

It's not point-and-clicky, and it's got no UI to speak of, but gnuplot is so powerful that it's probably why there aren't any contenders under Linux. It's ancient (in development since 1986), baroquely documented (the answer's in there, somewhere), supports lots of legacy devices you'll probably never need but isn't ever going away. And, of course it supports unix timestamps as dates.

Install with:

Code: Select all

sudo apt install gnuplot-x11 gnuplot-doc gnuplot-data
The gnuplot-x11 detail is important: there's a no-X version that gives you no interactive preview. Handy for data pipelines, not so much for visualisation.

I made a fake CSV 10 minute data for ~36 hours source using this shell command:

Code: Select all

seq $(date --date='2021-06-03 00:10' +%s) 600 $(date --date='2021-06-03 00:10 36 hour' +%s) | while read d; do echo "${d},$((RANDOM % 40))"; done > arbitrary.csv
On my system it looks like this. Yours will be different:

Code: Select all

1622693400,38
1622694000,8
1622694600,14
 …
1622821800,28
1622822400,10
1622823000,36
Here's a very plain set of commands to plot this as points:

Code: Select all

set terminal wxt 0 enhanced
set datafile separator ","
#set datafile nocolumnheaders
set xdata time
set timefmt "%s"
set format x "%H:%M"
set ylabel "arbitrary units"
set key off
plot "arbitrary.csv" using 1:2 pointtype 2
You can either start gnuplot and paste/type that into the command shell, or save it as arbitrary.gnuplot (say) and plot it with:

Code: Select all

gnuplot -p arbitrary.gnuplot
and you should get something like:
gnuplot.png
gnuplot demo
gnuplot.png (33.66 KiB) Viewed 391 times
While gnuplot's incredibly powerful, it's not obviously flexible. In this very simple plot:
  • the export/save as button doesn't work if it's called via gnuplot -p for annoying reasons;
  • try as I might, I couldn't get the points plotted in the green colour you used.
There are books on gnuplot, and there are online examples that get astonishing results. You can script it so you'll get exactly the same plot options for different data files. But it's got a fierce learning curve, and it may not be for everyone
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

dbrion06
Posts: 690
Joined: Tue May 28, 2019 11:57 am

Re: recommend scientific graphing program?

Wed Jun 23, 2021 12:27 pm

May be gnuolot is too difficult. Then a solution would be to use GNU-octave (a matlab free clone: ten years ago, it piped into ... gnuplot to have nice plots; this option remains -is necessary for huge numbers - https://octave.org/doc/v4.2.2/Introduct ... tting.html)...

User avatar
scruss
Posts: 4485
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: recommend scientific graphing program?

Wed Jun 23, 2021 3:47 pm

There's a java front-end for it that looks like someone's at least thought about how things should work: GitHub - hopandfork/jgnuplot: Java graphical frontend for gnuplot: setup your plots faster
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “General discussion”