Jae-Won Chung commited on
Commit
35a3eb4
1 Parent(s): 8c3360c

Only show model names on hover (#12)

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -205,11 +205,12 @@ class TableManager:
205
 
206
  # Strip the <a> tag from model names.
207
  text = self.cur_df["model"].apply(lambda x: x.split(">")[1].split("<")[0])
 
208
  if z is None or z == "None" or z == "":
209
- fig = px.scatter(self.cur_df, x=x, y=y, text=text)
210
  else:
211
- fig = px.scatter_3d(self.cur_df, x=x, y=y, z=z, text=text)
212
- fig.update_traces(textposition="top center")
213
  fig.update_layout(width=width, height=height)
214
 
215
  return fig, width, height, ""
@@ -334,6 +335,7 @@ with block:
334
  checkbox.change(TableManager.set_filter_get_df, inputs=[tbm, *checkboxes], outputs=dataframe)
335
 
336
  # Block 3: Allow users to add new columns.
 
337
  with gr.Row():
338
  with gr.Column(scale=3):
339
  with gr.Row():
@@ -376,6 +378,7 @@ with block:
376
  )
377
 
378
  # Block 4: Allow users to plot 2D and 3D scatter plots.
 
379
  with gr.Row():
380
  with gr.Column(scale=3):
381
  with gr.Row():
 
205
 
206
  # Strip the <a> tag from model names.
207
  text = self.cur_df["model"].apply(lambda x: x.split(">")[1].split("<")[0])
208
+ # Hide model names since they clutter the plots, and only show them on hover.
209
  if z is None or z == "None" or z == "":
210
+ fig = px.scatter(self.cur_df, x=x, y=y, hover_name=text)
211
  else:
212
+ fig = px.scatter_3d(self.cur_df, x=x, y=y, z=z, hover_name=text)
213
+ fig.update_traces(marker=dict(size=12, line=dict(width=2, color="DarkSlateGrey")))
214
  fig.update_layout(width=width, height=height)
215
 
216
  return fig, width, height, ""
 
335
  checkbox.change(TableManager.set_filter_get_df, inputs=[tbm, *checkboxes], outputs=dataframe)
336
 
337
  # Block 3: Allow users to add new columns.
338
+ gr.Markdown("---\n### Add custom columns to the table")
339
  with gr.Row():
340
  with gr.Column(scale=3):
341
  with gr.Row():
 
378
  )
379
 
380
  # Block 4: Allow users to plot 2D and 3D scatter plots.
381
+ gr.Markdown("---\n### Scatter plot (Hover over marker to show model name)")
382
  with gr.Row():
383
  with gr.Column(scale=3):
384
  with gr.Row():