use mathplotlib to draw data from csv file
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 3 Mar 2017 08:53:57 +0000 (09:53 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 3 Mar 2017 08:53:57 +0000 (09:53 +0100)
graph.py [new file with mode: 0755]

diff --git a/graph.py b/graph.py
new file mode 100755 (executable)
index 0000000..14a3365
--- /dev/null
+++ b/graph.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.dates as mdates
+
+if __name__=="__main__":
+    t, a, b, c, d, e, f, g, temp = np.loadtxt("temp.csv", unpack=True,
+    delimiter=',',
+        converters={
+            #0: mdates.strpdate2num('%Y-%m-%dT%H:%M:%S'),
+            #0: mdates.epoch2num(),
+            #0: lambda s: float(s.strip() or 0),
+        }
+        )
+    print t
+
+    t = mdates.epoch2num(t)
+    print t
+
+    ax = plt.subplot(511)
+    ax.plot_date(t, a, 'b-', linewidth=0.5)
+
+    ax.format_xdata = mdates.DateFormatter("%Y-%m-%d %H:%M:%S")
+    ax.grid(True)
+
+    plt.plot_date(t, b, 'r-', linewidth=0.5)
+
+    plt.subplot(512, sharex = ax)
+    plt.plot_date(t, temp, 'y-', linewidth=0.5)
+
+    plt.subplot(513, sharex = ax)
+    plt.plot_date(t, c, 'c-', linewidth=0.5)
+
+    plt.subplot(514, sharex = ax)
+    plt.plot_date(t, d, 'b-', linewidth=0.5)
+
+    plt.subplot(515, sharex = ax)
+    plt.plot_date(t, e, '-')
+
+    plt.subplot(515, sharex = ax)
+    plt.plot_date(t, f, '-')
+
+    plt.subplot(513, sharex = ax)
+    plt.plot_date(t, g, '-')
+
+
+    plt.show()
+