shiny.ui.output_plot#

shiny.ui.output_plot(id, width='100%', height='400px', inline=False)#

Create a output container for a static plot.

Place a plot() result in the user interface. See plot() for more details on what types of plots are supported.

Parameters
  • id (str) – An input id.

  • width (str) – The CSS width, e.g. ‘400px’, or ‘100%’

  • height (str) – The CSS height, e.g. ‘100%’ or ‘600px’

  • inline (bool) – If True, the result is displayed inline

Return type

A UI element

See also

plot, output_image

Example

#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
from shiny import *
import numpy as np
import matplotlib.pyplot as plt

app_ui = ui.page_fluid(
    ui.input_slider(
        "n", "input_slider()", min=10, max=100, value=50, step=5, animate=True
    ),
    ui.output_plot("p"),
)

def server(input: Inputs, output: Outputs, session: Session):
    @output
    @render.plot
    def p():
        np.random.seed(19680801)
        x_rand = 100 + 15 * np.random.randn(437)
        fig, ax = plt.subplots()
        ax.hist(x_rand, int(input.n()), density=True)
        return fig


app = App(app_ui, server)