diff --git a/src/stravavis/plot_landscape.py b/src/stravavis/plot_landscape.py index 6de6d5e..6ad21e2 100644 --- a/src/stravavis/plot_landscape.py +++ b/src/stravavis/plot_landscape.py @@ -1,5 +1,7 @@ import matplotlib.pyplot as plt import pandas as pd +from rich.progress import track + def plot_landscape(df, output_file = 'landscape.png'): @@ -11,25 +13,24 @@ def plot_landscape(df, output_file = 'landscape.png'): # Create a list of activity names activities = df['name'].unique() - n = len(activities) - + # Normalize dist processed = [] - - for i in range(n): - df_i = df[df['name'] == activities[i]] + + for activity in track(activities, "Processing tracks"): + df_i = df[df['name'] == activity] df_i["dist_norm"] = (df_i["dist"] - df_i["dist"].min()) / (df_i["dist"].max() - df_i["dist"].min()) processed.append(df_i) - + df = pd.concat(processed) - + # Plot activities one by one - for i in range(n): - X = df[df['name'] == activities[i]]['dist_norm'] - Y = df[df['name'] == activities[i]]['ele'] - plt.fill_between(X, Y, color = 'black', alpha = 0.03, linewidth = 0) - plt.plot(X, Y, color = 'black', alpha = 0.125, linewidth = 0.25) - + for activity in track(activities, "Plotting activities"): + x = df[df['name'] == activity]['dist_norm'] + y = df[df['name'] == activity]['ele'] + plt.fill_between(x, y, color='black', alpha=0.03, linewidth=0) + plt.plot(x, y, color='black', alpha=0.125, linewidth=0.25) + # Update plot aesthetics plt.axis('off') plt.margins(0) diff --git a/src/stravavis/plot_map.py b/src/stravavis/plot_map.py index 5eb7fe1..f466b5e 100644 --- a/src/stravavis/plot_map.py +++ b/src/stravavis/plot_map.py @@ -1,4 +1,6 @@ import matplotlib.pyplot as plt +from rich.progress import track + def plot_map(df, lon_min=None, lon_max= None, lat_min=None, lat_max=None, alpha=0.3, linewidth=0.3, output_file="map.png"): @@ -21,13 +23,12 @@ def plot_map(df, lon_min=None, lon_max= None, lat_min=None, lat_max=None, # Create a list of activity names activities = df['name'].unique() - n = len(activities) # Plot activities one by one - for i in range(n): - X = df[df['name'] == activities[i]]['lon'] - Y = df[df['name'] == activities[i]]['lat'] - plt.plot(X, Y, color = 'black', alpha = alpha, linewidth = linewidth) + for activity in track(activities, "Plotting activities"): + x = df[df['name'] == activity]['lon'] + y = df[df['name'] == activity]['lat'] + plt.plot(x, y, color='black', alpha=alpha, linewidth=linewidth) # Update plot aesthetics plt.axis('off')