sleep_data / draw_db.py
thelou1s's picture
draw screen_list with up_down_list
eb8dea9
raw
history blame
1.83 kB
import matplotlib.pyplot as plt
import debug
from debug import debug_print
def draw(x_points=None, y_points=None):
plt.plot(x_points)
plt.ylim(ymin=0, ymax=120)
plt.show()
def draw_two(title='', x_list1=None, x_list2=None):
fig, ax = plt.subplots()
ax.plot(x_list1)
ax.plot(x_list2)
ax.legend()
plt.ylim(ymin=0, ymax=120)
plt.title(title)
plt.show()
def up_down_list(list):
min_value = min(list)
max_value = max(list)
return [-(x - min_value) + max_value for x in list]
def draw_three(title='', date_list=None, x_list1=None, x_list2=None, x_list3=None, light_list=None, screen_list=None):
debug_print('draw_three, date_list = ', str(date_list))
if screen_list is not None:
screen_list = [(x - 2) * 4 for x in screen_list]
screen_list = up_down_list(screen_list)
# screen_list = map(lambda x: (x - 2) * 4, screen_list)
fig, ax = plt.subplots()
if date_list is None:
ax.plot(screen_list, label='screen', color='darkgrey')
ax.plot(light_list, label='light', color='lightgrey')
ax.plot(x_list1, label='max', color='blue')
ax.plot(x_list2, label='min', color='orange')
ax.plot(x_list3, label='acc', color='green')
else:
ax.plot(date_list, screen_list, label='screen', color='darkgrey')
ax.plot(date_list, light_list, label='light', color='lightgrey')
ax.plot(date_list, x_list1, label='max', color='blue')
ax.plot(date_list, x_list2, label='min', color='orange')
ax.plot(date_list, x_list3, label='acc', color='green')
ax.legend()
plt.gcf().autofmt_xdate()
plt.ylim(ymin=-10, ymax=130)
plt.title(title)
if debug.DEBUG:
plt.show()
else:
file_uri = '.doc/' + title + '.png'
plt.savefig(file_uri)