Spaces:

ehsk commited on
Commit
366eb95
1 Parent(s): 6af31c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -6,7 +6,7 @@ import streamlit as st
6
 
7
  st.set_page_config(layout="wide")
8
  DATA_FILE = "data/anthology-2020-23_specter2_base.json"
9
-
10
 
11
  def load_df(data_file: os.PathLike):
12
  df = pd.read_json(data_file, orient="records")
@@ -39,6 +39,8 @@ with st.sidebar:
39
  )
40
  author_names = st.text_input("Author names (separated by comma)")
41
 
 
 
42
  start_year = int(start_year)
43
  end_year = int(end_year)
44
  df = DF[(DF["year"] >= start_year) & (DF["year"] <= end_year)]
@@ -55,18 +57,23 @@ with st.sidebar:
55
  )
56
  df = df[author_mask]
57
 
 
 
 
58
  st.write(f"Number of points: {df.shape[0]}")
59
 
 
 
60
 
61
  fig = px.scatter(
62
  df,
63
  x="x",
64
  y="y",
65
- color="cluster",
66
  width=1000,
67
  height=800,
68
  hover_data=["title", "authors", "year", "source", "type"],
69
- color_continuous_scale="fall",
70
  )
71
  fig.update_layout(
72
  # margin=dict(l=10, r=10, t=10, b=10),
@@ -79,5 +86,4 @@ fig.update_layout(
79
  fig.update_xaxes(title="")
80
  fig.update_yaxes(title="")
81
 
82
-
83
- st.plotly_chart(fig, use_container_width=True)
 
6
 
7
  st.set_page_config(layout="wide")
8
  DATA_FILE = "data/anthology-2020-23_specter2_base.json"
9
+ THEMES = {"cluster": "fall", "year": "mint", "source": "phase"}
10
 
11
  def load_df(data_file: os.PathLike):
12
  df = pd.read_json(data_file, orient="records")
 
39
  )
40
  author_names = st.text_input("Author names (separated by comma)")
41
 
42
+ title = st.text_input("Title")
43
+
44
  start_year = int(start_year)
45
  end_year = int(end_year)
46
  df = DF[(DF["year"] >= start_year) & (DF["year"] <= end_year)]
 
57
  )
58
  df = df[author_mask]
59
 
60
+ if title:
61
+ df = df[df.title.apply(lambda x: title.lower() in x.lower())]
62
+
63
  st.write(f"Number of points: {df.shape[0]}")
64
 
65
+ color = st.selectbox("Color", ("cluster", "year", "source"))
66
+
67
 
68
  fig = px.scatter(
69
  df,
70
  x="x",
71
  y="y",
72
+ color=color,
73
  width=1000,
74
  height=800,
75
  hover_data=["title", "authors", "year", "source", "type"],
76
+ color_continuous_scale=THEMES[color],
77
  )
78
  fig.update_layout(
79
  # margin=dict(l=10, r=10, t=10, b=10),
 
86
  fig.update_xaxes(title="")
87
  fig.update_yaxes(title="")
88
 
89
+ st.plotly_chart(fig, use_container_width=True)