Jupyter Notebooks have support for many kinds of interactive outputs. These should all be supported in MyST-NB by passing the output HTML through automatically.
This page has a few common examples. First off, we'll download a little bit of data and show its structure:
import plotly.express as px
data = px.data.iris()
data.head()
import altair as alt
alt.Chart(data=data).mark_point().encode(
x="sepal_width",
y="sepal_length",
color="species",
size='sepal_length'
)
Plotly is another interactive plotting library that provides a high-level API for visualization. You can display plotly plots like so:
import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", size="sepal_length")
fig
from bokeh.plotting import figure, show, output_notebook
output_notebook()
p = figure()
p.circle(data["sepal_width"], data["sepal_length"], color=data["species"])
You may also run code for Jupyter Widgets in your document, and the interactive HTML outputs will embed themselves in your side.
Here is an example from ipyvolume:
import ipywidgets as widgets
widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='Test:',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)
tab_contents = ['P0', 'P1', 'P2', 'P3', 'P4']
children = [widgets.Text(description=name) for name in tab_contents]
tab = widgets.Tab()
tab.children = children
tab.titles = [str(i) for i in range(len(children))]
tab