Page 1 of 1

Temperature and hours daily plotting

Posted: Wed Apr 23, 2014 1:28 pm
by Gigabyte2
Hi, I have written a Python program for controlling a peppers greenhouse.
The program reads temperature and humidity from a sensors but now I want to create a plot with these values.
How I can generate a simple plot with 24 hours range?

Thank you ;)

Re: Temperature and hours daily plotting

Posted: Wed Apr 23, 2014 1:53 pm
by DougieLawson
sudo apt-get install python{,3}-matplotlib

Code: Select all

#!/usr/bin/python3

import matplotlib.pyplot as pyplot

labels = ['04:00', '05:00', '06:00', '07:00']
x = [0.1667, 0.2083, 0.2500, 0.2916]
y = [12, 13, 14.5, 17.3]

pyplot.plot(x,y)
pyplot.show()
I'll leave it for you to add the labels to the x-axis.

There's a get started guide at: http://www.ucs.cam.ac.uk/docs/course-no ... graphs.pdf

Re: Temperature and hours daily plotting

Posted: Wed Apr 23, 2014 2:01 pm
by MattHawkinsUK
Weird. I've just written a blog post on plotting data from a sensor log using gnuplot. Dougie's answer if probably best if you want to keep it all within Python.

gnuplot is quite handy when you are experimenting but you need the data in a separate text file.

Re: Temperature and hours daily plotting

Posted: Wed Apr 23, 2014 2:16 pm
by DougieLawson
MattHawkinsUK wrote: Dougie's answer if probably best if you want to keep it all within Python.
I assumed that since the question appeared in the Python sub-forum.

Re: Temperature and hours daily plotting

Posted: Wed Apr 23, 2014 2:18 pm
by DougieLawson
MattHawkinsUK wrote:Weird. I've just written a blog post on plotting data from a sensor log using gnuplot.
Thanks for sharing a well written article with pretty examples.

Re: Temperature and hours daily plotting

Posted: Wed Apr 23, 2014 3:10 pm
by iinnovations
If you're in web pages, I suggest jqplot.

Go here (http://cupidcontrol.com/mobile/dataviewer.html) enter viewer/viewer, toggle the log button, and hit refresh plot to see what this looks like.

Colin

Re: Temperature and hours daily plotting

Posted: Wed Apr 23, 2014 8:54 pm
by TrevorAppleton
There are loads of good examples of plotting graphs already mentioned in this post. I have a couple of blog posts which show how to plot graphs from within Python which are very easy to do.

http://trevorappleton.blogspot.co.uk/se ... bel/Graphs