2121# Set style for better looking plots
2222plt .style .use ("seaborn-v0_8-darkgrid" )
2323sns .set_theme (style = "whitegrid" , palette = "deep" )
24- plt .rcParams [' figure.facecolor' ] = ' #f8f9fa'
25- plt .rcParams [' axes.facecolor' ] = ' #ffffff'
26- plt .rcParams [' grid.alpha' ] = 0.2
24+ plt .rcParams [" figure.facecolor" ] = " #f8f9fa"
25+ plt .rcParams [" axes.facecolor" ] = " #ffffff"
26+ plt .rcParams [" grid.alpha" ] = 0.2
2727
2828
2929def run_git_command (cmd ):
@@ -234,9 +234,13 @@ def create_contribution_graphs(
234234 title_suffix = f" ({ year } , { month_names [month - 1 ]} -Dec)"
235235 else :
236236 output_base = f"kdevops_contributions_{ year } _{ month_names [month - 1 ].lower ()} _{ month_names [end_month - 1 ].lower ()} "
237- title_suffix = f" ({ year } , { month_names [month - 1 ]} -{ month_names [end_month - 1 ]} )"
237+ title_suffix = (
238+ f" ({ year } , { month_names [month - 1 ]} -{ month_names [end_month - 1 ]} )"
239+ )
238240 else :
239- output_base = f"kdevops_contributions_{ year } _{ month_names [month - 1 ].lower ()} _dec"
241+ output_base = (
242+ f"kdevops_contributions_{ year } _{ month_names [month - 1 ].lower ()} _dec"
243+ )
240244 title_suffix = f" ({ year } , { month_names [month - 1 ]} -Dec)"
241245 else :
242246 output_base = f"kdevops_contributions_{ year } "
@@ -246,7 +250,7 @@ def create_contribution_graphs(
246250 title_suffix = " (All Time)"
247251
248252 # Create figure with multiple subplots and better styling
249- fig = plt .figure (figsize = (24 , 16 ), facecolor = ' #f8f9fa' )
253+ fig = plt .figure (figsize = (24 , 16 ), facecolor = " #f8f9fa" )
250254 gs = fig .add_gridspec (
251255 3 ,
252256 3 ,
@@ -259,7 +263,7 @@ def create_contribution_graphs(
259263 fontsize = 24 ,
260264 fontweight = "bold" ,
261265 y = 0.985 ,
262- color = ' #2c3e50'
266+ color = " #2c3e50" ,
263267 )
264268
265269 if not contributors_total :
@@ -272,7 +276,7 @@ def create_contribution_graphs(
272276 commits = list (contributors_total .values ())
273277
274278 # Use a professional color gradient
275- cmap = plt .colormaps [' viridis' ]
279+ cmap = plt .colormaps [" viridis" ]
276280 colors = [cmap (i / len (contributors )) for i in range (len (contributors ))]
277281
278282 # Limit to top 15 contributors for readability
@@ -281,11 +285,19 @@ def create_contribution_graphs(
281285 commits = commits [:15 ]
282286 colors = colors [:15 ]
283287
284- bars = ax1 .bar (contributors , commits , color = colors , edgecolor = '#2c3e50' , linewidth = 1.5 )
285- ax1 .set_title ("Total Commits by Contributor" , fontweight = "bold" , fontsize = 16 , color = '#2c3e50' , pad = 20 )
286- ax1 .set_ylabel ("Number of Commits" , fontsize = 12 , color = '#34495e' )
287- ax1 .spines ['top' ].set_visible (False )
288- ax1 .spines ['right' ].set_visible (False )
288+ bars = ax1 .bar (
289+ contributors , commits , color = colors , edgecolor = "#2c3e50" , linewidth = 1.5
290+ )
291+ ax1 .set_title (
292+ "Total Commits by Contributor" ,
293+ fontweight = "bold" ,
294+ fontsize = 16 ,
295+ color = "#2c3e50" ,
296+ pad = 20 ,
297+ )
298+ ax1 .set_ylabel ("Number of Commits" , fontsize = 12 , color = "#34495e" )
299+ ax1 .spines ["top" ].set_visible (False )
300+ ax1 .spines ["right" ].set_visible (False )
289301
290302 # Improve x-axis labels for better readability
291303 ax1 .tick_params (axis = "x" , rotation = 45 , labelsize = 8 )
@@ -347,11 +359,19 @@ def create_contribution_graphs(
347359 autopct = "" , # No percentage text in the pie
348360 startangle = 90 ,
349361 colors = pie_colors ,
350- explode = [0.05 if i == 0 else 0 for i in range (len (main_contributors ))], # Slightly explode the largest slice
362+ explode = [
363+ 0.05 if i == 0 else 0 for i in range (len (main_contributors ))
364+ ], # Slightly explode the largest slice
351365 shadow = True ,
352- wedgeprops = {'edgecolor' : 'white' , 'linewidth' : 2 }
366+ wedgeprops = {"edgecolor" : "white" , "linewidth" : 2 },
367+ )
368+ ax2 .set_title (
369+ "Contribution Distribution" ,
370+ fontweight = "bold" ,
371+ fontsize = 16 ,
372+ color = "#2c3e50" ,
373+ pad = 20 ,
353374 )
354- ax2 .set_title ("Contribution Distribution" , fontweight = "bold" , fontsize = 16 , color = '#2c3e50' , pad = 20 )
355375
356376 # Calculate percentages for legend
357377 total_value = sum (main_contributors .values ())
@@ -401,7 +421,9 @@ def create_contribution_graphs(
401421 activity_matrix .append (monthly_commits )
402422
403423 if activity_matrix and months :
404- im = ax3 .imshow (activity_matrix , cmap = "coolwarm" , aspect = "auto" , interpolation = 'nearest' )
424+ im = ax3 .imshow (
425+ activity_matrix , cmap = "coolwarm" , aspect = "auto" , interpolation = "nearest"
426+ )
405427 ax3 .set_xticks (range (len (months )))
406428 month_names = [
407429 "Jan" ,
@@ -420,7 +442,13 @@ def create_contribution_graphs(
420442 ax3 .set_xticklabels ([month_names [m - 1 ] for m in months ])
421443 ax3 .set_yticks (range (len (top_contributors )))
422444 ax3 .set_yticklabels (top_contributors )
423- ax3 .set_title ("Monthly Activity Heatmap" , fontweight = "bold" , fontsize = 16 , color = '#2c3e50' , pad = 20 )
445+ ax3 .set_title (
446+ "Monthly Activity Heatmap" ,
447+ fontweight = "bold" ,
448+ fontsize = 16 ,
449+ color = "#2c3e50" ,
450+ pad = 20 ,
451+ )
424452
425453 # Add text annotations
426454 for i in range (len (top_contributors )):
@@ -470,7 +498,9 @@ def create_contribution_graphs(
470498 current_date = datetime .now ()
471499 if (year is None ) or (int (year ) == current_date .year ):
472500 # Only include months up to current month
473- months_with_data = sorted ([m for m in monthly_totals .keys () if m <= current_date .month ])
501+ months_with_data = sorted (
502+ [m for m in monthly_totals .keys () if m <= current_date .month ]
503+ )
474504 else :
475505 months_with_data = sorted (monthly_totals .keys ())
476506 month_names = [
@@ -499,32 +529,50 @@ def create_contribution_graphs(
499529 color = "#3498db" ,
500530 markerfacecolor = "#e74c3c" ,
501531 markeredgewidth = 2 ,
502- markeredgecolor = "#2c3e50"
532+ markeredgecolor = "#2c3e50" ,
503533 )
504534 ax4 .fill_between (
505535 months_with_data ,
506536 [monthly_totals [m ] for m in months_with_data ],
507537 alpha = 0.2 ,
508538 color = "#3498db" ,
509539 )
510- ax4 .set_title ("Monthly Commit Activity" , fontweight = "bold" , fontsize = 16 , color = '#2c3e50' , pad = 20 )
511- ax4 .spines ['top' ].set_visible (False )
512- ax4 .spines ['right' ].set_visible (False )
540+ ax4 .set_title (
541+ "Monthly Commit Activity" ,
542+ fontweight = "bold" ,
543+ fontsize = 16 ,
544+ color = "#2c3e50" ,
545+ pad = 20 ,
546+ )
547+ ax4 .spines ["top" ].set_visible (False )
548+ ax4 .spines ["right" ].set_visible (False )
513549 ax4 .set_xlabel ("Month" )
514550 ax4 .set_ylabel ("Total Commits" )
515551 # FORCE matplotlib to use ONLY our specified ticks
516552 ax4 .set_xticks (months_with_data )
517553 ax4 .set_xticks (months_with_data , minor = False ) # No minor ticks
518554 ax4 .set_xticklabels ([month_names [m - 1 ] for m in months_with_data ])
519- ax4 .xaxis .set_tick_params (which = 'minor' , bottom = False , top = False ) # Disable minor ticks
555+ ax4 .xaxis .set_tick_params (
556+ which = "minor" , bottom = False , top = False
557+ ) # Disable minor ticks
520558 ax4 .grid (True , alpha = 0.3 )
521559
522560 # Add a subtle 'Today' marker within the current year for context
523561 if year and int (year ) == current_date .year :
524- days_in_month = calendar .monthrange (current_date .year , current_date .month )[1 ]
525- today_pos = current_date .month + (current_date .day - 1 ) / float (days_in_month )
562+ days_in_month = calendar .monthrange (
563+ current_date .year , current_date .month
564+ )[1 ]
565+ today_pos = current_date .month + (current_date .day - 1 ) / float (
566+ days_in_month
567+ )
526568 if 1 <= today_pos <= 12 :
527- ax4 .axvline (x = today_pos , color = "#7f8c8d" , linestyle = ":" , linewidth = 1.5 , alpha = 0.7 )
569+ ax4 .axvline (
570+ x = today_pos ,
571+ color = "#7f8c8d" ,
572+ linestyle = ":" ,
573+ linewidth = 1.5 ,
574+ alpha = 0.7 ,
575+ )
528576 ax4 .text (
529577 today_pos ,
530578 max ([monthly_totals [m ] for m in months_with_data ]) * 0.6 ,
@@ -595,7 +643,6 @@ def create_contribution_graphs(
595643 # 5. Top Contributors Timeline
596644 ax5 = fig .add_subplot (gs [1 , 1 ])
597645
598-
599646 if active_months :
600647 top_3_contributors = list (contributors_total .keys ())[:3 ]
601648 # Use distinctive colors with good contrast
@@ -633,15 +680,19 @@ def create_contribution_graphs(
633680 color = colors_line [idx % len (colors_line )],
634681 alpha = 0.8 ,
635682 markeredgewidth = 2 ,
636- markeredgecolor = ' #2c3e50'
683+ markeredgecolor = " #2c3e50" ,
637684 )
638685
639686 ax5 .set_title (
640- "Top Contributors Monthly Activity" , fontweight = "bold" , fontsize = 16 , color = '#2c3e50' , pad = 20
687+ "Top Contributors Monthly Activity" ,
688+ fontweight = "bold" ,
689+ fontsize = 16 ,
690+ color = "#2c3e50" ,
691+ pad = 20 ,
641692 )
642693 ax5 .set_xlabel ("Month" )
643- ax5 .spines [' top' ].set_visible (False )
644- ax5 .spines [' right' ].set_visible (False )
694+ ax5 .spines [" top" ].set_visible (False )
695+ ax5 .spines [" right" ].set_visible (False )
645696 ax5 .set_ylabel ("Commits" )
646697 # Only show months with actual activity (filtering out future months)
647698 if (year is None ) or (int (year ) == current_date .year ):
@@ -667,7 +718,9 @@ def create_contribution_graphs(
667718 "Dec" ,
668719 ]
669720 ax5 .set_xticklabels ([month_names [m - 1 ] for m in valid_months ])
670- ax5 .xaxis .set_tick_params (which = 'minor' , bottom = False , top = False ) # Disable minor ticks
721+ ax5 .xaxis .set_tick_params (
722+ which = "minor" , bottom = False , top = False
723+ ) # Disable minor ticks
671724 ax5 .legend (fontsize = 10 )
672725 ax5 .grid (True , alpha = 0.3 )
673726
@@ -682,10 +735,22 @@ def create_contribution_graphs(
682735
683736 # Add a subtle 'Today' marker for context on current year
684737 if year and int (year ) == current_date .year :
685- days_in_month = calendar .monthrange (current_date .year , current_date .month )[1 ]
686- today_pos = current_date .month + (current_date .day - 1 ) / float (days_in_month )
687- if valid_months and (min (valid_months ) - 0.5 ) <= today_pos <= (max (valid_months ) + 0.5 ):
688- ax5 .axvline (x = today_pos , color = "#7f8c8d" , linestyle = ":" , linewidth = 1.5 , alpha = 0.7 )
738+ days_in_month = calendar .monthrange (current_date .year , current_date .month )[
739+ 1
740+ ]
741+ today_pos = current_date .month + (current_date .day - 1 ) / float (
742+ days_in_month
743+ )
744+ if valid_months and (min (valid_months ) - 0.5 ) <= today_pos <= (
745+ max (valid_months ) + 0.5
746+ ):
747+ ax5 .axvline (
748+ x = today_pos ,
749+ color = "#7f8c8d" ,
750+ linestyle = ":" ,
751+ linewidth = 1.5 ,
752+ alpha = 0.7 ,
753+ )
689754 # Use the max commits across visible data for label height
690755 _max_y = 0
691756 for contributor in list (contributors_total .keys ())[:3 ]:
@@ -765,11 +830,15 @@ def create_contribution_graphs(
765830 # When viewing current year or all-time, ignore future months in stats too
766831 current_date = datetime .now ()
767832 if (year is None ) or (int (year ) == current_date .year ):
768- filtered_totals = {m : v for m , v in monthly_totals .items () if m <= current_date .month }
833+ filtered_totals = {
834+ m : v for m , v in monthly_totals .items () if m <= current_date .month
835+ }
769836 else :
770837 filtered_totals = dict (monthly_totals )
771838 most_active_month = (
772- max (filtered_totals .items (), key = lambda x : x [1 ]) if filtered_totals else None
839+ max (filtered_totals .items (), key = lambda x : x [1 ])
840+ if filtered_totals
841+ else None
773842 )
774843 month_names = [
775844 "Jan" ,
@@ -791,7 +860,9 @@ def create_contribution_graphs(
791860 most_active_month_commits = most_active_month [1 ] if most_active_month else 0
792861 # Count active months within the considered range
793862 if (year is None ) or (int (year ) == current_date .year ):
794- active_months_count = len (set (m for (c , m ) in monthly_data .keys () if m <= current_date .month ))
863+ active_months_count = len (
864+ set (m for (c , m ) in monthly_data .keys () if m <= current_date .month )
865+ )
795866 else :
796867 active_months_count = len (set (m for (c , m ) in monthly_data .keys ()))
797868 else :
@@ -849,9 +920,9 @@ def create_contribution_graphs(
849920 facecolor = "#ecf0f1" ,
850921 edgecolor = "#34495e" ,
851922 linewidth = 2 ,
852- alpha = 0.9
923+ alpha = 0.9 ,
853924 ),
854- color = ' #2c3e50'
925+ color = " #2c3e50" ,
855926 )
856927
857928 # 7. Generated-by Tag Adoption Trend
@@ -893,13 +964,13 @@ def create_contribution_graphs(
893964 "Generated-by Tag Adoption Over Time" ,
894965 fontweight = "bold" ,
895966 fontsize = 16 ,
896- color = ' #2c3e50' ,
967+ color = " #2c3e50" ,
897968 pad = 20 ,
898969 )
899- ax7 .set_ylabel ("Commits with Generated-by" , fontsize = 12 , color = ' #34495e' )
900- ax7 .set_xlabel ("Month" , fontsize = 12 , color = ' #34495e' )
901- ax7 .spines [' top' ].set_visible (False )
902- ax7 .spines [' right' ].set_visible (False )
970+ ax7 .set_ylabel ("Commits with Generated-by" , fontsize = 12 , color = " #34495e" )
971+ ax7 .set_xlabel ("Month" , fontsize = 12 , color = " #34495e" )
972+ ax7 .spines [" top" ].set_visible (False )
973+ ax7 .spines [" right" ].set_visible (False )
903974 ax7 .grid (True , alpha = 0.3 )
904975 ax7 .set_ylim (bottom = 0 )
905976 ax7 .tick_params (axis = "x" , labelrotation = 45 )
@@ -924,7 +995,10 @@ def create_contribution_graphs(
924995
925996 if (year is None ) or (int (year ) == datetime .now ().year ):
926997 current_marker = datetime .now ()
927- if timeline_dates and timeline_dates [0 ] <= current_marker <= timeline_dates [- 1 ]:
998+ if (
999+ timeline_dates
1000+ and timeline_dates [0 ] <= current_marker <= timeline_dates [- 1 ]
1001+ ):
9281002 ax7 .axvline (
9291003 current_marker ,
9301004 color = "#7f8c8d" ,
@@ -940,8 +1014,8 @@ def create_contribution_graphs(
9401014 color = "#2c3e50" ,
9411015 pad = 20 ,
9421016 )
943- ax7 .spines [' top' ].set_visible (False )
944- ax7 .spines [' right' ].set_visible (False )
1017+ ax7 .spines [" top" ].set_visible (False )
1018+ ax7 .spines [" right" ].set_visible (False )
9451019 ax7 .set_ylabel ("Commits with Generated-by" , fontsize = 12 , color = "#34495e" )
9461020 ax7 .set_xlabel ("Month" , fontsize = 12 , color = "#34495e" )
9471021 ax7 .tick_params (axis = "x" , labelbottom = False )
0 commit comments