Skip to content

Commit

Permalink
prototype shiny flat mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Oct 18, 2023
1 parent 5eaa4c6 commit f0a13e3
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions docs/dashboards/_examples/shiny-flat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

import seaborn as sns
from shiny import ui, reactive, render
penguins = sns.load_dataset("penguins")

@reactive.Calc
def filtered_penguins():
data = penguins[penguins["species"].isin(input.species())]
data = data[data["island"].isin(input.islands())]
return data

ui.page(orientation = "columns")

ui.navigation(title = "Palmer Penguins")

with ui.sidebar():

ui.markdown("![](images/penguins.png){width=80%}")

species = list(penguins["species"].value_counts().index)
ui.input_checkbox_group(
"species", "Species:",
species, selected = species
)

islands = list(penguins["island"].value_counts().index)
ui.input_checkbox_group(
"islands", "Islands:",
islands, selected = islands
)

ui.markdown("***")

ui.input_select("dist", "Distribution:", choices=["kde", "hist"])
ui.input_checkbox("rug", "Show rug marks", value = False)

ui.markdown(
"""
***
[Learn more](https://pypi.org/project/palmerpenguins/) about
the Palmer Penguins dataset."
""")


with ui.column():

with ui.row(height = "65%"):

@render.plot
def depth():
return sns.displot(
filtered_penguins(), x = "bill_depth_mm",
hue = "species", kind = input.dist(),
fill = True, rug=input.rug()
)

@render.plot
def length():
return sns.displot(
filtered_penguins(), x = "bill_length_mm",
hue = "species", kind = input.dist(),
fill = True, rug=input.rug()
)

with ui.row(height = "35%"):

@render.data_frame
def dataview():
return render.DataGrid(filtered_penguins())

0 comments on commit f0a13e3

Please sign in to comment.