@@ -46,17 +46,25 @@ def _plotMetric(self, metricName: str, unit: str):
46
46
df = df .sort_values (by = [metricName ], ascending = False )
47
47
grouped = df .groupby (by = ["Name" ])
48
48
49
- fig = plt .figure (figsize = (8 , 15 ))
49
+ ncols = 2
50
+ nrows = len (grouped ) // ncols + len (grouped ) % ncols
51
+ fig , axes = plt .subplots (ncols = ncols , nrows = nrows , figsize = (ncols * 8 , nrows * 2.4 ))
50
52
fig .suptitle (f"{ metricName } comparison" , fontsize = 24 )
51
53
54
+ # Clear axes
52
55
for i , (names , group ) in enumerate (grouped ):
53
- ax = plt . subplot ( len ( grouped ), 1 , i + 1 )
56
+ ax = axes [ i // ncols , i % ncols ]
54
57
colors = [self .colorMap [lib ] for lib in group ["Library" ]]
55
58
ax .barh (y = group ["Library" ], width = group [metricName ], color = colors )
56
59
ax .set_title (names [0 ])
57
60
ax .set_xlabel (unit )
58
- ax .plot ()
61
+
62
+ remaining = len (grouped ) % ncols
63
+ for i in range (remaining ):
64
+ # Remove empty axes
65
+ ax = axes [nrows - 1 , ncols - i - 1 ]
66
+ fig .delaxes (ax )
59
67
60
68
fileName = metricName .replace (" " , "_" ).replace ("/" , "_" ).lower ()
61
- plt .subplots_adjust (wspace = 0 , hspace = 0.8 )
69
+ plt .subplots_adjust (wspace = 0.2 , hspace = 1 )
62
70
plt .savefig (os .path .join (self .dir , f"{ fileName } .png" ))
0 commit comments