badgiec
Posts: 2
Joined: Wed Nov 08, 2017 9:21 pm

Recommendations for best way to graph my data

Thu Nov 09, 2017 1:32 pm

Posting in Python forum but solution I’m looking for doesn’t necessarily have to be python but ideally can be executable in my existing python program at at least should be able to schedule the graph program to run via cron.

I’ve got a python script recording movement detected by a PIR sensor and logged in a text file with a second text file being used to record the hourly totals. The files are sent via email daily.

I’d like to enhance the program now with graphical representation of the log data but I haven’t done this before and don’t know the best program to use. Ideally I’d like to send the graph on email too - presumably .jpg format is best way.
The graph would have time on x axis in intervals of one minute with the y axis being binary to represent movement (1) or no movement (0).

The input for the graph is the log file with these elements:
Date
Start time of movement
End time of movement
Total duration of movement (difference in end and start time)

The elements in the summary file are similar but have HOUR instead of Start and End Times and the duration is a total for that hour. This file will not be of any use for plotting the graph.

I know I may need to manipulate the input to obtain binary values for each minute. That won’t be an issue.

Any suggestions on best way to graph this would be appreciated.

User avatar
ksharindam
Posts: 164
Joined: Sat Jan 09, 2016 4:16 pm

Re: Recommendations for best way to graph my data

Thu Nov 09, 2017 4:58 pm

As you have said that it is not necessarily be a python program, you can use gnuplot. It can plot your graph.
You can also use the python wrapper gnuplot.py (http://gnuplot-py.sourceforge.net/).

And if you want to create a plotter manually, you can use draw functions of PIL library and draw the plot.

stijn.ghesquiere
Posts: 26
Joined: Sat May 19, 2012 9:44 pm

Re: Recommendations for best way to graph my data

Mon Nov 13, 2017 6:11 pm

Or you transport the data to a system as Emoncms (https://emoncms.org/, open source). They have a raspberry pi version (disk image). In Emoncms you can watch the data in all kinds of graphs, also real-time in a web interface. It's very efficient in logging data. (I use it to log and watch activity of my animals). Connecting to emoncms is simple with python.
It also contains MQTT and Node Red to work/reroute/connect with the data.
Just my 2 cents...

badgiec
Posts: 2
Joined: Wed Nov 08, 2017 9:21 pm

Re: Recommendations for best way to graph my data

Wed Nov 15, 2017 1:23 pm

Thanks ksharindam & stijn.ghesquiere. I've never used either of these so I'm going to read up on both to understand which is most suitable for my project.

Return to “Python”