import sqlite3 import matplotlib.pyplot as plt import matplotlib.dates as mdates import numpy as np import datetime con = sqlite3.connect("data.db") cur = con.cursor() res = cur.execute("SELECT time, watts FROM data") x_values = [] y_values = [] for time, watts in res: x_values.append(datetime.datetime.fromtimestamp(time / 1000)) y_values.append(watts) fig, ax = plt.subplots() ax.plot(x_values, y_values) 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()