saattrupdan commited on
Commit
65f7993
·
1 Parent(s): e5b38af

feat: Add scaling sliders of plot

Browse files
Files changed (1) hide show
  1. app.py +45 -14
app.py CHANGED
@@ -177,19 +177,37 @@ def main() -> None:
177
  interactive=True,
178
  scale=2,
179
  )
180
- with gr.Column():
181
- use_win_ratio_checkbox = gr.Checkbox(
182
- label="Compare models with win ratios (as opposed to raw scores)",
183
- value=True,
184
- interactive=True,
185
- scale=1,
186
- )
187
- show_scale_checkbox = gr.Checkbox(
188
- label="Show scale on plot",
189
- value=False,
190
- interactive=True,
191
- scale=1,
192
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  with gr.Row():
194
  plot = gr.Plot(
195
  value=produce_radial_plot(
@@ -197,6 +215,8 @@ def main() -> None:
197
  language_names=language_names_dropdown.value,
198
  use_win_ratio=use_win_ratio_checkbox.value,
199
  show_scale=show_scale_checkbox.value,
 
 
200
  results_dfs=results_dfs,
201
  ),
202
  )
@@ -220,6 +240,8 @@ def main() -> None:
220
  language_names_dropdown,
221
  use_win_ratio_checkbox,
222
  show_scale_checkbox,
 
 
223
  ],
224
  outputs=plot,
225
  )
@@ -227,6 +249,8 @@ def main() -> None:
227
  model_ids_dropdown.change(**update_plot_kwargs)
228
  use_win_ratio_checkbox.change(**update_plot_kwargs)
229
  show_scale_checkbox.change(**update_plot_kwargs)
 
 
230
 
231
  demo.launch()
232
 
@@ -315,6 +339,8 @@ def produce_radial_plot(
315
  language_names: list[str],
316
  use_win_ratio: bool,
317
  show_scale: bool,
 
 
318
  results_dfs: dict[Language, pd.DataFrame] | None,
319
  ) -> go.Figure:
320
  """Produce a radial plot as a plotly figure.
@@ -328,6 +354,10 @@ def produce_radial_plot(
328
  Whether to use win ratios (as opposed to raw scores).
329
  show_scale:
330
  Whether to show the scale on the plot.
 
 
 
 
331
  results_dfs:
332
  The results dataframes for each language.
333
 
@@ -443,7 +473,8 @@ def produce_radial_plot(
443
  polar=dict(radialaxis=dict(visible=show_scale, range=[0, 100])),
444
  showlegend=True,
445
  title=title,
446
- width=800,
 
447
  )
448
 
449
  logger.info("Successfully produced radial plot.")
 
177
  interactive=True,
178
  scale=2,
179
  )
180
+ with gr.Row():
181
+ use_win_ratio_checkbox = gr.Checkbox(
182
+ label="Compare models with win ratios (as opposed to raw scores)",
183
+ value=True,
184
+ interactive=True,
185
+ scale=1,
186
+ )
187
+ show_scale_checkbox = gr.Checkbox(
188
+ label="Show the scale on the plot (always 0-100)",
189
+ value=False,
190
+ interactive=True,
191
+ scale=1,
192
+ )
193
+ plot_width_slider = gr.Slider(
194
+ label="Plot width",
195
+ minimum=600,
196
+ maximum=1000,
197
+ step=10,
198
+ value=800,
199
+ interactive=True,
200
+ scale=1,
201
+ )
202
+ plot_height_slider = gr.Slider(
203
+ label="Plot height",
204
+ minimum=300,
205
+ maximum=700,
206
+ step=10,
207
+ value=500,
208
+ interactive=True,
209
+ scale=1,
210
+ )
211
  with gr.Row():
212
  plot = gr.Plot(
213
  value=produce_radial_plot(
 
215
  language_names=language_names_dropdown.value,
216
  use_win_ratio=use_win_ratio_checkbox.value,
217
  show_scale=show_scale_checkbox.value,
218
+ plot_width=plot_width_slider.value,
219
+ plot_height=plot_height_slider.value,
220
  results_dfs=results_dfs,
221
  ),
222
  )
 
240
  language_names_dropdown,
241
  use_win_ratio_checkbox,
242
  show_scale_checkbox,
243
+ plot_width_slider,
244
+ plot_height_slider,
245
  ],
246
  outputs=plot,
247
  )
 
249
  model_ids_dropdown.change(**update_plot_kwargs)
250
  use_win_ratio_checkbox.change(**update_plot_kwargs)
251
  show_scale_checkbox.change(**update_plot_kwargs)
252
+ plot_width_slider.change(**update_plot_kwargs)
253
+ plot_height_slider.change(**update_plot_kwargs)
254
 
255
  demo.launch()
256
 
 
339
  language_names: list[str],
340
  use_win_ratio: bool,
341
  show_scale: bool,
342
+ plot_width: int,
343
+ plot_height: int,
344
  results_dfs: dict[Language, pd.DataFrame] | None,
345
  ) -> go.Figure:
346
  """Produce a radial plot as a plotly figure.
 
354
  Whether to use win ratios (as opposed to raw scores).
355
  show_scale:
356
  Whether to show the scale on the plot.
357
+ plot_width:
358
+ The width of the plot.
359
+ plot_height:
360
+ The height of the plot.
361
  results_dfs:
362
  The results dataframes for each language.
363
 
 
473
  polar=dict(radialaxis=dict(visible=show_scale, range=[0, 100])),
474
  showlegend=True,
475
  title=title,
476
+ width=plot_width,
477
+ height=plot_height,
478
  )
479
 
480
  logger.info("Successfully produced radial plot.")