Esempio n. 1
0
 def __graph_multiple(cls, time, data_list, stat_name, period, ylabel_list,
                      yrange_list, save):
     title = f'{stat_name} by {period}'
     figure = plt.figure(figsize=GarminDBConfigManager.get_graphs('size'))
     for index, data in enumerate(data_list):
         color = Colors.from_integer(index).name
         axes = figure.add_subplot(111,
                                   label=ylabel_list[index],
                                   frame_on=(index == 0))
         axes.plot(time, data, color=color)
         axes.set_ylabel(ylabel_list[index], color=color)
         axes.yaxis.set_label_position(
             YAxisLabelPostion.from_integer(index).name)
         if (index % 2) == 0:
             axes.yaxis.tick_right()
         else:
             axes.yaxis.tick_left()
         axes.tick_params(axis='y', colors=color)
         if yrange_list is None:
             axes.set_ylim([min(data), max(data)])
         else:
             axes.set_ylim(yrange_list[index])
         axes.grid()
     axes.set_title(title)
     axes.set_xlabel('Time')
     if save:
         figure.savefig(stat_name + ".png")
     plt.show()
Esempio n. 2
0
 def __graph_multiple_single_axes(cls, time, data_list, stat_name, ylabel,
                                  save):
     title = f'{stat_name} Over Time'
     figure = plt.figure(figsize=GarminDBConfigManager.get_graphs('size'))
     for index, data in enumerate(data_list):
         color = Colors.from_integer(index).name
         axes = figure.add_subplot(111, frame_on=(index == 0))
         axes.plot(time, data, color=color)
         axes.grid()
     axes.set_title(title)
     axes.set_xlabel('Time')
     axes.set_ylabel(ylabel)
     if save:
         figure.savefig(stat_name + ".png")
     plt.show()
Esempio n. 3
0
 def __graph_over(cls,
                  date,
                  over_data_dicts,
                  under_data_dict,
                  title,
                  xlabel,
                  ylabel,
                  save_name=None):
     figure = plt.figure(figsize=GarminDBConfigManager.get_graphs('size'))
     # First graph the data that appears under
     axes = figure.add_subplot(111, frame_on=True)
     axes.fill_between(under_data_dict['time'],
                       under_data_dict['data'],
                       0,
                       color=Colors.c.name)
     axes.set_ylim(under_data_dict['limits'])
     axes.set_xticks([])
     axes.set_yticks([])
     # then graph the data that appears on top
     colors = [Colors.r.name, Colors.b.name]
     for index, _ in enumerate(over_data_dicts):
         over_data_dict = over_data_dicts[index]
         color = colors[index]
         label = over_data_dict['label']
         axes = figure.add_subplot(111, frame_on=False, label=label)
         axes.plot(over_data_dict['time'],
                   over_data_dict['data'],
                   color=color)
         axes.set_ylabel(label, color=color)
         axes.yaxis.set_label_position(
             YAxisLabelPostion.from_integer(index).name)
         if (index % 2) == 0:
             axes.yaxis.tick_right()
             axes.set_xticks([])
         else:
             axes.yaxis.tick_left()
         limits = over_data_dicts[index].get('limits')
         if limits is not None:
             axes.set_ylim(limits)
         axes.grid()
     axes.set_title(title)
     axes.set_xlabel(xlabel)
     x_format = mdates.DateFormatter('%H:%M')
     axes.xaxis.set_major_formatter(x_format)
     if save_name:
         figure.savefig(save_name)
     plt.show()