22
33import requests
44import matplotlib .pyplot as plt
5- from datetime import datetime
5+ from datetime import datetime , timedelta
66from pprint import pformat
77
88import numpy as np
@@ -58,7 +58,8 @@ def fetch_download_data(api_url: str) -> dict:
5858def plot_downloads (data : dict ) -> None :
5959 """Plots number of downloads and cumulative downloads over time using matplotlib.
6060
61- Includes total cumulative in the title.
61+ Includes total cumulative in the title and annotates a specific event date with
62+ styled text.
6263
6364 Args:
6465 data (dict): A dictionary with dates as keys and download counts as values.
@@ -82,9 +83,28 @@ def plot_downloads(data: dict) -> None:
8283 color = "r" ,
8384 label = "Cumulative Downloads" ,
8485 )
86+
87+ # Annotation for the release download button addition
88+ event_date = datetime (2024 , 5 , 9 , 2 , 46 ) # Year, Month, Day, Hour, Minute
89+ plt .axvline (x = event_date , color = "g" , linestyle = ":" , label = "Download Buttons Added" )
90+ plt .annotate (
91+ "Download Buttons Added at\n www.openadapt.ai" ,
92+ xy = (event_date , plt .ylim ()[0 ] + 100 ),
93+ xytext = (
94+ event_date - timedelta (days = 10 ),
95+ plt .ylim ()[1 ] * 0.85 ,
96+ ), # Shift left by 10 days
97+ horizontalalignment = "center" ,
98+ fontsize = 10 ,
99+ bbox = dict (
100+ boxstyle = "round,pad=0.5" , edgecolor = "green" , facecolor = "#ffffcc" , alpha = 0.9
101+ ),
102+ )
103+
85104 current_time = datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )
86105 plt .title (
87- "Downloads Over Time"
106+ "github.com/OpenAdaptAI/OpenAdapt"
107+ "\n Release Downloads Over Time"
88108 f"\n (Total Cumulative: { total_cumulative_downloads } ) "
89109 f"\n { current_time } "
90110 )
0 commit comments