Spaces:
Runtime error
Runtime error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +38 -24
src/streamlit_app.py
CHANGED
|
@@ -76,39 +76,53 @@ def make_band(df, thickness=20):
|
|
| 76 |
human_band = make_band(df_human)
|
| 77 |
synth_band = make_band(df_synth)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
| 79 |
COMMON_LEN = 500
|
| 80 |
t_common = np.linspace(0, 1, COMMON_LEN)
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
)
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
synth_band[0]
|
| 92 |
-
)
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
y=["Human", "Synthetic"],
|
| 103 |
colorscale="Plasma",
|
| 104 |
-
showscale=False
|
| 105 |
-
|
|
|
|
| 106 |
|
| 107 |
fig.update_layout(
|
| 108 |
-
height=
|
| 109 |
-
margin=dict(l=10, r=10, t=
|
| 110 |
-
|
| 111 |
-
yaxis=dict(showticklabels=False),
|
| 112 |
)
|
| 113 |
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
human_band = make_band(df_human)
|
| 77 |
synth_band = make_band(df_synth)
|
| 78 |
|
| 79 |
+
# --- REPLACEMENT STARTS HERE ---
|
| 80 |
+
from plotly.subplots import make_subplots
|
| 81 |
+
|
| 82 |
COMMON_LEN = 500
|
| 83 |
t_common = np.linspace(0, 1, COMMON_LEN)
|
| 84 |
|
| 85 |
+
# Interpolate to smooth the data
|
| 86 |
+
human_interp = np.interp(t_common, df_human["t_norm"].values, df_human["roll_var_norm"])
|
| 87 |
+
synth_interp = np.interp(t_common, df_synth["t_norm"].values, df_synth["roll_var_norm"])
|
| 88 |
+
|
| 89 |
+
# Create a subplot with 2 rows.
|
| 90 |
+
# "vertical_spacing" is the magic number for your gap! (0.1 = 10% gap)
|
| 91 |
+
fig = make_subplots(
|
| 92 |
+
rows=2, cols=1,
|
| 93 |
+
shared_xaxes=True,
|
| 94 |
+
vertical_spacing=0.15, # <--- ADJUST THIS to make the gap bigger/smaller
|
| 95 |
+
subplot_titles=("Human: Big Flame", f"Synthetic: {choice.title()}")
|
| 96 |
)
|
| 97 |
|
| 98 |
+
# Helper to make the bands "thick" so they look like strips, not thin lines
|
| 99 |
+
def make_thick_band(data_row, thickness=10):
|
| 100 |
+
return [data_row] * thickness
|
|
|
|
|
|
|
| 101 |
|
| 102 |
+
# Add Human Trace (Top)
|
| 103 |
+
fig.add_trace(go.Heatmap(
|
| 104 |
+
z=make_thick_band(human_interp),
|
| 105 |
+
colorscale="Plasma",
|
| 106 |
+
showscale=False,
|
| 107 |
+
zmin=0, zmax=1 # Lock colors so they are comparable
|
| 108 |
+
), row=1, col=1)
|
| 109 |
|
| 110 |
+
# Add Synthetic Trace (Bottom)
|
| 111 |
+
fig.add_trace(go.Heatmap(
|
| 112 |
+
z=make_thick_band(synth_interp),
|
|
|
|
| 113 |
colorscale="Plasma",
|
| 114 |
+
showscale=False,
|
| 115 |
+
zmin=0, zmax=1
|
| 116 |
+
), row=2, col=1)
|
| 117 |
|
| 118 |
fig.update_layout(
|
| 119 |
+
height=350, # Made it slightly taller to accommodate the gap
|
| 120 |
+
margin=dict(l=10, r=10, t=50, b=10),
|
| 121 |
+
xaxis2_title="Normalized Interaction Time", # Label only the bottom axis
|
|
|
|
| 122 |
)
|
| 123 |
|
| 124 |
+
# Hide the y-axis ticks for a cleaner look
|
| 125 |
+
fig.update_yaxes(showticklabels=False, showgrid=False, zeroline=False)
|
| 126 |
+
fig.update_xaxes(showgrid=False, zeroline=False)
|
| 127 |
+
|
| 128 |
+
st.plotly_chart(fig, use_container_width=True)
|