
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# original from https://shinylive.io/py/examples/#altair
from shiny.express import input, ui
from shinywidgets import render_altair
ui.input_selectize("var", "Select variable", choices=["bill_length_mm", "body_mass_g"])
@render_altair
def hist():
import altair as alt
from palmerpenguins import load_penguins
df = load_penguins()
return (
alt.Chart(df)
.mark_bar()
.encode(x=alt.X(f"{input.var()}:Q", bin=True), y="count()")
)