def graph_per_month_running(master_dict,choice_dict,unit_dict,days_total):
    input1 = days_total
    input2 = 'distance_miles'

    graph_dict = {}
    for choice in choice_dict:
        graph_dict[choice] = calc.full_running_totals(master_dict.copy(),input1,input2) #duplicates data dictionary into number of months given

    for date_range,choice in zip(graph_dict,choice_dict):
        for key in list(graph_dict[date_range].keys()):
            if key < get_time.FOM(choice_dict[choice]) or key > get_time.LOM(choice_dict[choice]):  #
                del graph_dict[date_range][key] #eliminates keys older or newer than specified for each month

        y_list = []
        for key in sorted(graph_dict[date_range].keys()):
            y_list.append(graph_dict[date_range][key]) #gets y values
        x_list = list(range(1,len(list(graph_dict[date_range].keys()))+1)) #calculates x values based on y values

        plt.plot(x_list,y_list,label=(get_time.what_month(get_time.FOM(choice_dict[choice]).month)+" "+str(get_time.FOM(choice_dict[choice]).year)))

    plt.style.use('dark_background')
    plt.rcParams['lines.linewidth'] = 1
    plt.ylim(ymin=0)
    plt.title('Running Total - ' + str(input1) + ' days, Unit: ' + input2)
    plt.legend()
    plt.show()
Esempio n. 2
0
import matplotlib.pyplot as plt
import pylab
import matplotlib.dates as mdates
import numpy as np
from pprint import pprint

master_dict = get_data.my_filtered_activities() #grabs dictionary of strava information

input1 = 90 #Blue
input4 = 365 #Red
input2 = 'distance_miles'
input3 = 12 #months back to graph

graph_dict_1 = {}

graph_dict_1 = calc.full_running_totals(master_dict.copy(),input1,input2)

for key in list(graph_dict_1.keys()):
    if key < get_time.FOM(input3):
        del graph_dict_1[key]

graph_dict_2 = {}

graph_dict_2 = calc.full_running_totals(master_dict.copy(),input4,input2)

for key in list(graph_dict_2.keys()):
    if key < get_time.FOM(input3):
        del graph_dict_2[key]


def graph(master_dict,unit):
    #elapsed_time, distance_miles, average_speed, kudos_count, max_heartrate, average_heartrate, max_speed, pace_dec, total_elevation_gain,
    #athlete_count, average_temp, achivement_count
    input1 = 7
    input2 = 'distance_miles'

    x_list = []
    y_list = []
    x2_list = []
    y2_list = []
    x3_list = []
    y3_list = []
    x4_list = []
    y4_list = []

    graph_dict = calc.full_running_totals(master_dict,input1,input2)
    graph_dict1 = graph_dict.copy()
    graph_dict2 = graph_dict.copy()
    graph_dict3 = graph_dict.copy()
    graph_dict4 = graph_dict.copy()

    for key in list(graph_dict1):
        if key < get_time.FOM(0):
            del graph_dict1[key]
    for key in list(graph_dict1):
       if key > get_time.LOM(0):
           del graph_dict1[key]

    for key in sorted(graph_dict1.keys()):
        x_list.append(key)
        y_list.append(graph_dict1[key])
    len_x = len(x_list)
    x_list2 = range(len_x)

    for key in list(graph_dict2):
        if key < get_time.FOM(1):
            del graph_dict2[key]
    for key in list(graph_dict2):
       if key > get_time.LOM(1):
           del graph_dict2[key]

    for key in sorted(graph_dict2.keys()):
        x2_list.append(key)
        y2_list.append(graph_dict2[key])
    len_x2 = len(x2_list)
    x2_list2 = range(len_x2)

    for key in list(graph_dict3):
        if key < get_time.FOM(2):
            del graph_dict3[key]
    for key in list(graph_dict3):
       if key > get_time.LOM(2):
           del graph_dict3[key]
    for key in sorted(graph_dict3.keys()):
        x3_list.append(key)
        y3_list.append(graph_dict3[key])
    len_x3 = len(x3_list)
    x3_list2 = range(len_x3)

    for key in list(graph_dict4):
        if key < get_time.FOM(3):
            del graph_dict4[key]
    for key in list(graph_dict4):
       if key > get_time.LOM(3):
           del graph_dict4[key]
    for key in sorted(graph_dict4.keys()):
        x4_list.append(key)
        y4_list.append(graph_dict4[key])
    len_x4 = len(x4_list)
    x4_list2 = range(len_x4)

    plt.style.use('dark_background')
    #plt.axis('off')
    plt.rcParams['lines.linewidth'] = 1
    plt.plot(x_list2,y_list, color='red')
    plt.plot(x2_list2,y2_list, color='blue')
    plt.plot(x3_list2,y3_list, color='green')
    plt.plot(x4_list2,y4_list, color='yellow')
    plt.ylim(ymin=0)
    plt.title('Previous 4 Months - ' + str(input1) + ' days total, Unit: ' + input2)


    #print(plt.style.available)
    plt.legend([get_time.what_month(get_time.FOM(0).month), get_time.what_month(get_time.FOM(1).month), get_time.what_month(get_time.FOM(2).month), get_time.what_month(get_time.FOM(3).month)], loc='best')
    plt.show()
def graph(master_dict,unit):
    #elapsed_time, distance_miles, average_speed, kudos_count, max_heartrate, average_heartrate, max_speed, pace_dec, total_elevation_gain,
    #athlete_count, average_temp, achivement_count
    input1 = 7
    input2 = 'distance_miles'

    x_list = []
    y_list = []
    x2_list = []
    y2_list = []
    x3_list = []
    y3_list = []
    x4_list = []
    y4_list = []

    graph_dict = calc.full_running_totals(master_dict,input1,input2)
    graph_dict1 = graph_dict.copy()
    graph_dict2 = graph_dict.copy()
    graph_dict3 = graph_dict.copy()
    graph_dict4 = graph_dict.copy()

    for key in list(graph_dict1):
        if key < get_time.LM(0): #if time is greater than now
            del graph_dict1[key]
    # for key in list(graph_dict1):
    #    if key > get_time.LS(0):
    #        del graph_dict1[key]
    for key in sorted(graph_dict1.keys()):
        x_list.append(key)
        y_list.append(graph_dict1[key])
    len_x = len(x_list)
    x_list2 = range(len_x)


    for key in list(graph_dict2):
        if key < get_time.LM(1):
            del graph_dict2[key]
    for key in list(graph_dict2):
       if key > get_time.LS(0):
           del graph_dict2[key]
    for key in sorted(graph_dict2.keys()):
        x2_list.append(key)
        y2_list.append(graph_dict2[key])
    len_x2 = len(x2_list)
    x2_list2 = range(len_x2)

    for key in list(graph_dict3):
        if key < get_time.LM(2):
            del graph_dict3[key]
    for key in list(graph_dict3):
       if key > get_time.LS(1):
           del graph_dict3[key]
    for key in sorted(graph_dict3.keys()):
        x3_list.append(key)
        y3_list.append(graph_dict3[key])
    len_x3 = len(x3_list)
    x3_list2 = range(len_x3)

    for key in list(graph_dict4):
        if key < get_time.LM(3):
            del graph_dict4[key]
    for key in list(graph_dict4):
       if key > get_time.LS(2):
           del graph_dict4[key]
    for key in sorted(graph_dict4.keys()):
        x4_list.append(key)
        y4_list.append(graph_dict4[key])
    len_x4 = len(x4_list)
    x4_list2 = range(len_x4)

    #x_list2 = x2_list2 = x3_list2 = x4_list2 = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
    plt.style.use('dark_background')
    #plt.axis('off')
    plt.rcParams['lines.linewidth'] = 2
    plt.plot(x_list2,y_list, color='red')
    plt.plot(x2_list2,y2_list, color='blue')
    plt.plot(x3_list2,y3_list, color='green')
    plt.plot(x4_list2,y4_list, color='yellow')
    plt.title('Previous 4 Weeks (Monday - Sunday) - ' + str(input1) + ' days total, Unit: ' + input2)
    #plt.ylim(ymin=0)
    label1 = calc.month_day(get_time.LM(0))+" - "+calc.month_day(get_time.LS(-1))
    label2 = calc.month_day(get_time.LM(1))+" - "+calc.month_day(get_time.LS(0))
    label3 = calc.month_day(get_time.LM(2))+" - "+calc.month_day(get_time.LS(1))
    label4 = calc.month_day(get_time.LM(3))+" - "+calc.month_day(get_time.LS(2))

    #print(plt.style.available)
    plt.legend([label1, label2, label3, label4], loc='best')
    plt.show()
Esempio n. 5
0
master_dict = get_data.my_filtered_activities(
)  #grabs dictionary of strava information
# for x in master_dict:
#     print(master_dict[x]['map']['summary_polyline'])

input1 = 365  #Blue
input2 = 90  #Red
input3 = 30  #
input4 = 8  #
input5 = 7
input6 = 1

months_back = 15

graph_dict_1 = {}
graph_dict_1 = calc.full_running_totals(master_dict.copy(), input1,
                                        'distance_miles')

for key in list(graph_dict_1.keys()):
    if key < get_time.FOM(months_back):
        del graph_dict_1[key]

#
graph_dict_2 = {}
graph_dict_2 = calc.full_running_totals(master_dict.copy(), input2,
                                        'distance_miles')

for key in list(graph_dict_2.keys()):
    if key < get_time.FOM(months_back):
        del graph_dict_2[key]

#
Esempio n. 6
0
def running_totals():
    input1 = 365  #Blue
    input2 = 90  #Red
    input3 = 30  #
    input4 = 8  #
    input5 = 7
    input6 = 1

    months_back = 15

    graph_dict_1 = {}
    graph_dict_1 = calc.full_running_totals(master_dict.copy(), input1,
                                            'distance_miles')

    for key in list(graph_dict_1.keys()):
        if key < get_time.FOM(months_back):
            del graph_dict_1[key]

    #
    graph_dict_2 = {}
    graph_dict_2 = calc.full_running_totals(master_dict.copy(), input2,
                                            'distance_miles')

    for key in list(graph_dict_2.keys()):
        if key < get_time.FOM(months_back):
            del graph_dict_2[key]

    #
    graph_dict_3 = {}
    graph_dict_3 = calc.full_running_totals(master_dict.copy(), input3,
                                            'distance_miles')

    for key in list(graph_dict_3.keys()):
        if key < get_time.FOM(months_back):
            del graph_dict_3[key]

    #
    graph_dict_4 = {}
    graph_dict_4 = calc.full_running_totals(master_dict.copy(), input4,
                                            'distance_miles')

    for key in list(graph_dict_4.keys()):
        if key < get_time.FOM(months_back):
            del graph_dict_4[key]

    #
    graph_dict_5 = {}
    graph_dict_5 = calc.full_running_totals(master_dict.copy(), input5,
                                            'distance_miles')

    for key in list(graph_dict_5.keys()):
        if key < get_time.FOM(months_back):
            del graph_dict_5[key]

    #
    graph_dict_6 = {}
    graph_dict_6 = calc.full_running_totals(master_dict.copy(), input6,
                                            'distance_miles')

    for key in list(graph_dict_6.keys()):
        if key < get_time.FOM(months_back):
            del graph_dict_6[key]

    fig, (ax1, ax2, ax3, ax4, ax5,
          ax6) = plt.subplots(nrows=6,
                              figsize=mass_figsize)  #figsize sets window

    ax1.plot(list(graph_dict_1.keys()), list(graph_dict_1.values()), 'red')
    ax1.set_title(str(input1) + " Running Days Total")
    ax1.grid(True)

    ax2.plot(list(graph_dict_2.keys()), list(graph_dict_2.values()),
             'blue')  #set up third
    ax2.set_title(str(input2) + " Running Days Total")
    ax2.grid(True)

    ax3.plot(list(graph_dict_3.keys()), list(graph_dict_3.values()),
             'green')  #set up fourth graph
    ax3.set_title(str(input3) + " Running Days Total")
    ax3.grid(True)

    ax4.plot(list(graph_dict_4.keys()), list(graph_dict_4.values()),
             'red')  #set up fourth graph
    ax4.set_title(str(input4) + " Running Days Total")
    ax4.grid(True)

    ax5.plot(list(graph_dict_5.keys()), list(graph_dict_5.values()),
             'blue')  #set up fourth graph
    ax5.set_title(str(input5) + " Running Days Total")
    ax5.grid(True)

    ax6.plot(list(graph_dict_6.keys()), list(graph_dict_6.values()),
             'green')  #set up fourth graph
    ax6.set_title(str(input6) + " Running Days Total")
    ax6.grid(True)

    fig.subplots_adjust(hspace=0.3)
    fig.tight_layout()
    append_image("Running_Totals", plt)