Closed lostmygithubaccount closed 7 months ago
for added context this is desired for:
nothing in the linked discussion worked
I am able to reproduce this:
---
title: "Penguin Bills"
format: dashboard
server: shiny
---
```{python}
import seaborn as sns
import plotly.express as px
penguins = sns.load_dataset("penguins")
from shiny import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
ui.input_checkbox("rug", "Show rug marks", value = False)
@render.plot
def displot1():
return sns.displot(
data=penguins, hue="species", multiple="stack",
x=input.x(), rug=input.rug(), kind=input.dist())
@render.plot
def displot2():
return px.histogram(penguins, x=input.x(), color="species", marginal="rug",
histfunc="count", barmode="overlay")
@render.plot
def displot3():
# note the lack of `return`
sns.displot(
data=penguins, hue="species", multiple="stack",
x=input.x(), rug=input.rug(), kind=input.dist())
@render.plot
def displot4():
# note the lack of `return`
px.histogram(penguins, x=input.x(), color="species", marginal="rug",
histfunc="count", barmode="overlay")
Stick that in a file called `bills.qmd` and run
$ quarto render bills.qmd
to get
![image](https://github.com/quarto-dev/quarto-cli/assets/417981/62a022dc-a50d-47b8-8709-d184955148ab)
I am running quarto version 1.4.549 on Linux.
Notice that when `return`ing the object, I get an error message. When I don't return anything, I see a blank plot.
Is plotly expected to work with quarto + shiny dashboards?
Plotly plots aren't static images (like Seaborn), so you need to use @render_widget
(not @render.plot
) from shinywidgets
:
---
title: "Penguin Bills"
format: dashboard
server: shiny
---
```{python}
import seaborn as sns
import plotly.express as px
from shinywidgets import output_widget, render_widget
penguins = sns.load_dataset("penguins")
from shiny import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
ui.input_checkbox("rug", "Show rug marks", value = False)
@render_widget
def displot2():
return px.histogram(penguins, x=input.x(), color="species", marginal="rug",
histfunc="count", barmode="overlay")
<img width="1436" alt="Screenshot 2024-02-08 at 10 15 16 AM" src="https://github.com/quarto-dev/quarto-cli/assets/25964/03d9a8f1-77af-46d9-a7a2-d0ae411f33a0">
This is indeed a shiny question rather than a Quarto one, but I respect that our docs don't give you many pointers on how to get started with Shiny for Python and Quarto. I'll be looking at those docs soon, so I'll keep this issue in mind.
awesome, thanks @cwickham! that works
Bug description
I'm trying to have a UI input and use the value(s) of the input to adjust plotly charts. The inputs documentation for Quarto dashboards is all empty Python code blocks currently: https://quarto.org/docs/dashboards/inputs.html
I was able to find some examples:
While this seems to work fine with other plotting libraries, plotly charts don't seem to work and I'm not sure where to go from here.
Steps to reproduce
first example -- no Ibis:
{.sidebar}
Column
{height=25%}
{.toolbar}
plot
Quarto 1.4.549 [✓] Checking versions of quarto binary dependencies... Pandoc version 3.1.11: OK Dart Sass version 1.69.5: OK Deno version 1.37.2: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.4.549 Path: /Applications/quarto/bin
[✓] Checking tools....................OK TinyTeX: (not installed) Chromium: (not installed)
[✓] Checking LaTeX....................OK Tex: (not detected)
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK Version: 3.11.3 Path: /Users/cody/repos/pypi-analytics/venv/bin/python3 Jupyter: 5.7.1 Kernels: python3
[✓] Checking Jupyter engine render....OK
[✓] Checking R installation...........(None)