Skip to content

Commit 8834393

Browse files
committed
Bind radio switcher to figure
1 parent 7c1133f commit 8834393

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,13 @@ def n_bins_auto(res):
137137
return len(np.histogram_bin_edges(res.bins, bins="auto", range=(min_, max_))) - 1
138138

139139

140-
def figure(res, palette, n_bins, output_name):
140+
def figure(res, palette, n_bins, kind, output_name):
141+
kind = "histogram" if kind == "Stacked histogram" else "boxplot"
141142
plt.close("all")
142143
fig, ax = plt.subplots()
143-
_ = sd.visualization(bins=res.bins, palette=palette, n_bins=n_bins, ax=ax)
144+
_ = sd.visualization(
145+
bins=res.bins, palette=palette, n_bins=n_bins, kind=kind, ax=ax
146+
)
144147
ax.set(xlabel=output_name)
145148
return fig
146149

@@ -248,11 +251,19 @@ def tableau_states(res, states):
248251
format=PrintfTickFormatter(format="%d bins"),
249252
)
250253

254+
switch_histogram_boxplot = pn.widgets.RadioButtonGroup(
255+
name="Switch histogram - boxplot",
256+
options=["Stacked histogram", "Boxplot"],
257+
inline=False,
258+
width=400,
259+
)
260+
251261
interactive_figure = pn.bind(
252262
figure,
253263
interactive_decomposition,
254264
interactive_palette,
255265
selector_n_bins,
266+
switch_histogram_boxplot,
256267
selector_output,
257268
)
258269

@@ -317,6 +328,9 @@ def tableau_states(res, states):
317328
height_policy="min",
318329
)
319330
),
331+
pn.Spacer(height=50),
332+
switch_histogram_boxplot,
333+
pn.Spacer(height=50),
320334
selector_n_bins,
321335
),
322336
pn.Column(

0 commit comments

Comments
 (0)