Spaces:
Running
Running
Heatmap: Enabling visibility of the Y axis as an attribute and setting the font using a constant
Browse files- analyze_winscore.py +21 -5
analyze_winscore.py
CHANGED
|
@@ -215,7 +215,20 @@ def create_heatmap(data_matrix, original_scores,
|
|
| 215 |
plot_height=None,
|
| 216 |
x_axis_label="Model",
|
| 217 |
y_axis_label="Task",
|
|
|
|
|
|
|
| 218 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
if selected_rows is not None:
|
| 220 |
# Select only the specified rows (models)
|
| 221 |
data_matrix = data_matrix[selected_rows]
|
|
@@ -223,6 +236,7 @@ def create_heatmap(data_matrix, original_scores,
|
|
| 223 |
|
| 224 |
# Set up the figure with tasks as x-axis and models as y-axis
|
| 225 |
p = figure(
|
|
|
|
| 226 |
width=plot_width,
|
| 227 |
height=plot_height,
|
| 228 |
x_range=list(data_matrix.index),
|
|
@@ -297,16 +311,18 @@ def create_heatmap(data_matrix, original_scores,
|
|
| 297 |
p.xgrid.grid_line_color = None
|
| 298 |
p.ygrid.grid_line_color = None
|
| 299 |
p.xaxis.major_label_orientation = "vertical"
|
| 300 |
-
p.yaxis.major_label_text_font_size = "
|
| 301 |
-
p.xaxis.major_label_text_font_size = "
|
| 302 |
|
| 303 |
# Set the axis label font size
|
| 304 |
-
p.xaxis.axis_label_text_font_size = "
|
| 305 |
-
p.yaxis.axis_label_text_font_size = "
|
| 306 |
p.xaxis.axis_label_text_font_style = "normal" # Set x-axis label to normal
|
| 307 |
p.yaxis.axis_label_text_font_style = "normal" # Set y-axis label to normal
|
| 308 |
|
| 309 |
-
#
|
|
|
|
|
|
|
| 310 |
|
| 311 |
return p
|
| 312 |
|
|
|
|
| 215 |
plot_height=None,
|
| 216 |
x_axis_label="Model",
|
| 217 |
y_axis_label="Task",
|
| 218 |
+
x_axis_visible=True,
|
| 219 |
+
y_axis_visible=True,
|
| 220 |
):
|
| 221 |
+
FONTSIZE = 13
|
| 222 |
+
|
| 223 |
+
n_rows, n_cols = data_matrix.shape
|
| 224 |
+
y_axis_size = 0
|
| 225 |
+
x_axis_size = 0
|
| 226 |
+
cell_width_border = 1 + 3
|
| 227 |
+
cell_height_border = 4 + 3
|
| 228 |
+
cell_size = 30
|
| 229 |
+
plot_width = n_rows * cell_size + (n_rows * cell_width_border + y_axis_size if y_axis_visible else 0)
|
| 230 |
+
plot_height = n_cols * cell_size + (n_cols * cell_height_border + x_axis_size if x_axis_visible else 0)
|
| 231 |
+
|
| 232 |
if selected_rows is not None:
|
| 233 |
# Select only the specified rows (models)
|
| 234 |
data_matrix = data_matrix[selected_rows]
|
|
|
|
| 236 |
|
| 237 |
# Set up the figure with tasks as x-axis and models as y-axis
|
| 238 |
p = figure(
|
| 239 |
+
sizing_mode="fixed",
|
| 240 |
width=plot_width,
|
| 241 |
height=plot_height,
|
| 242 |
x_range=list(data_matrix.index),
|
|
|
|
| 311 |
p.xgrid.grid_line_color = None
|
| 312 |
p.ygrid.grid_line_color = None
|
| 313 |
p.xaxis.major_label_orientation = "vertical"
|
| 314 |
+
p.yaxis.major_label_text_font_size = f"{FONTSIZE}pt"
|
| 315 |
+
p.xaxis.major_label_text_font_size = f"{FONTSIZE}pt"
|
| 316 |
|
| 317 |
# Set the axis label font size
|
| 318 |
+
p.xaxis.axis_label_text_font_size = f"{FONTSIZE + 5}pt" # Set font size for x-axis label
|
| 319 |
+
p.yaxis.axis_label_text_font_size = f"{FONTSIZE + 5}pt" # Set font size for y-axis label
|
| 320 |
p.xaxis.axis_label_text_font_style = "normal" # Set x-axis label to normal
|
| 321 |
p.yaxis.axis_label_text_font_style = "normal" # Set y-axis label to normal
|
| 322 |
|
| 323 |
+
# Hide the axis labels
|
| 324 |
+
p.xaxis.visible = x_axis_visible
|
| 325 |
+
p.yaxis.visible = y_axis_visible
|
| 326 |
|
| 327 |
return p
|
| 328 |
|