Joschka Strueber commited on
Commit
1a7f19c
·
1 Parent(s): 60ded99

[Fix] force rendering of axes

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -5,27 +5,26 @@ from src.dataloading import get_leaderboard_models_cached, get_leaderboard_datas
5
 
6
  def create_heatmap(selected_models, selected_dataset):
7
  if not selected_models or not selected_dataset:
8
- return None # Return None to hide the plot if inputs are missing
9
-
10
  # Generate random similarity matrix
11
  size = len(selected_models)
12
  similarities = np.random.rand(size, size)
13
  similarities = (similarities + similarities.T) / 2 # Make symmetric
14
  similarities = np.round(similarities, 2) # Round for clarity
15
-
16
  # Create the heatmap figure
17
- fig = go.Figure()
18
- fig.add_trace(go.Heatmap(
19
  z=similarities,
20
  x=selected_models,
21
  y=selected_models,
22
  colorscale='Viridis',
23
  zmin=0, zmax=1,
24
- text=similarities, # Values to show on hover
25
  hoverinfo="text"
26
  ))
27
 
28
- # Update layout for overall figure settings
29
  fig.update_layout(
30
  title=f"Similarity Matrix for {selected_dataset}",
31
  xaxis_title="Models",
@@ -35,28 +34,26 @@ def create_heatmap(selected_models, selected_dataset):
35
  margin=dict(b=100, l=100)
36
  )
37
 
38
- # Force both axes to be categorical by explicitly specifying tick values and text
39
  fig.update_xaxes(
40
  type="category",
41
- tickmode="array",
42
- tickvals=selected_models,
43
- ticktext=selected_models,
44
  tickangle=45,
 
 
45
  automargin=True,
46
  showgrid=True,
47
  showticklabels=True
48
  )
49
  fig.update_yaxes(
50
  type="category",
51
- tickmode="array",
52
- tickvals=selected_models,
53
- ticktext=selected_models,
54
  automargin=True,
55
  showgrid=True,
56
  showticklabels=True
57
  )
58
 
59
- return fig # Return only the figure
60
 
61
 
62
  def validate_inputs(selected_models, selected_dataset):
 
5
 
6
  def create_heatmap(selected_models, selected_dataset):
7
  if not selected_models or not selected_dataset:
8
+ return None # Hide the plot if no selection
9
+
10
  # Generate random similarity matrix
11
  size = len(selected_models)
12
  similarities = np.random.rand(size, size)
13
  similarities = (similarities + similarities.T) / 2 # Make symmetric
14
  similarities = np.round(similarities, 2) # Round for clarity
15
+
16
  # Create the heatmap figure
17
+ fig = go.Figure(data=go.Heatmap(
 
18
  z=similarities,
19
  x=selected_models,
20
  y=selected_models,
21
  colorscale='Viridis',
22
  zmin=0, zmax=1,
23
+ text=similarities,
24
  hoverinfo="text"
25
  ))
26
 
27
+ # Update layout for title, size, margins, etc.
28
  fig.update_layout(
29
  title=f"Similarity Matrix for {selected_dataset}",
30
  xaxis_title="Models",
 
34
  margin=dict(b=100, l=100)
35
  )
36
 
37
+ # Force axes to be categorical and explicitly set the order
38
  fig.update_xaxes(
39
  type="category",
 
 
 
40
  tickangle=45,
41
+ categoryorder="array",
42
+ categoryarray=selected_models, # Explicitly force ordering to match your list
43
  automargin=True,
44
  showgrid=True,
45
  showticklabels=True
46
  )
47
  fig.update_yaxes(
48
  type="category",
49
+ categoryorder="array",
50
+ categoryarray=selected_models,
 
51
  automargin=True,
52
  showgrid=True,
53
  showticklabels=True
54
  )
55
 
56
+ return fig
57
 
58
 
59
  def validate_inputs(selected_models, selected_dataset):