Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,49 +1,19 @@
|
|
| 1 |
import panel as pn
|
| 2 |
-
import hvplot.pandas
|
| 3 |
|
| 4 |
-
|
| 5 |
-
from bokeh.sampledata.autompg import autompg_clean as df
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
# cylinders = pn.widgets.IntSlider(name='Cylinderssss', start=4, end=8, step=2)
|
| 12 |
-
mfr = pn.widgets.ToggleGroup(
|
| 13 |
-
name='MFR',
|
| 14 |
-
options=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
|
| 15 |
-
value=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
|
| 16 |
-
button_type='success')
|
| 17 |
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
name='Y axis',
|
| 21 |
-
options=['hp', 'weight'],
|
| 22 |
-
button_type='success'
|
| 23 |
-
)
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
(idf.mfr.isin(mfr))
|
| 30 |
-
]
|
| 31 |
-
.groupby(['origin', 'mpg'])[yaxis].mean()
|
| 32 |
-
.to_frame()
|
| 33 |
-
.reset_index()
|
| 34 |
-
.sort_values(by='mpg')
|
| 35 |
-
.reset_index(drop=True)
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
# Pipe to hvplot
|
| 39 |
-
ihvplot = ipipeline.hvplot(x='mpg', y=yaxis, by='origin', color=["#ff6f69", "#ffcc5c", "#88d8b0"], line_width=6, height=400)
|
| 40 |
-
|
| 41 |
-
# Layout using Template
|
| 42 |
-
template = pn.template.FastListTemplate(
|
| 43 |
-
title='EasySciRead',
|
| 44 |
-
sidebar=[cylinders, 'Manufacturers', mfr, 'Y axis' , yaxis],
|
| 45 |
-
main=[ihvplot.panel()],
|
| 46 |
-
accent_base_color="#88d8b0",
|
| 47 |
-
header_background="#88d8b0",
|
| 48 |
-
)
|
| 49 |
-
template.servable()
|
|
|
|
| 1 |
import panel as pn
|
|
|
|
| 2 |
|
| 3 |
+
pn.extension()
|
|
|
|
| 4 |
|
| 5 |
+
x = pn.widgets.Select(name='x', options=cols)
|
| 6 |
+
y = pn.widgets.Select(name='y', options=cols, value='bill_depth_mm')
|
| 7 |
+
n_clusters = pn.widgets.IntSlider(name='n_clusters', start=2, end=5, value=3)
|
| 8 |
|
| 9 |
+
explanation = pn.pane.Markdown(...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
def plot(x, y, n_clusters):
|
| 12 |
+
...
|
| 13 |
|
| 14 |
+
interactive_plot = pn.bind(plot, x, y, n_clusters)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
pn.Row(
|
| 17 |
+
pn.WidgetBox(x, y, n_clusters, explanation),
|
| 18 |
+
interactive_plot
|
| 19 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|