File size: 1,828 Bytes
f1f2090
eb8dea9
 
f13c4bb
f1f2090
 
 
 
6b4e7c6
 
f1f2090
 
 
6b4e7c6
f1f2090
 
 
 
6b4e7c6
 
 
f1f2090
 
6b4e7c6
eb8dea9
 
 
 
 
 
 
f13c4bb
 
eb8dea9
 
 
 
 
f1f2090
f13c4bb
eb8dea9
 
 
 
 
f13c4bb
eb8dea9
 
 
 
 
f1f2090
f13c4bb
6b4e7c6
eb8dea9
6b4e7c6
f13c4bb
eb8dea9
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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)