Import plot script
This commit is contained in:
parent
abe8b2a91e
commit
c35da3facc
1 changed files with 8 additions and 4 deletions
|
@ -1,6 +1,8 @@
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
import matplotlib.dates as mdates
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import datetime
|
||||||
|
|
||||||
con = sqlite3.connect("data.db")
|
con = sqlite3.connect("data.db")
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
@ -11,11 +13,13 @@ x_values = []
|
||||||
y_values = []
|
y_values = []
|
||||||
|
|
||||||
for time, watts in res:
|
for time, watts in res:
|
||||||
x_values.append(time)
|
x_values.append(datetime.datetime.fromtimestamp(time / 1000))
|
||||||
y_values.append(watts)
|
y_values.append(watts)
|
||||||
|
|
||||||
plt.plot(x_values, y_values)
|
fig, ax = plt.subplots()
|
||||||
|
ax.plot(x_values, y_values)
|
||||||
plt.ylim([0, 200])
|
plt.tick_params(rotation=45)
|
||||||
|
ax.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M - %d.%m"))
|
||||||
|
|
||||||
|
plt.ylim([0, max(y_values) + 50])
|
||||||
plt.show()
|
plt.show()
|
Loading…
Reference in a new issue