We’re excited to announce the release of JupyterDash, our new library that makes it easy to build Dash apps from Jupyter environments (e.g. classic Notebook, JupyterLab, Visual Studio Code notebooks, nteract, PyCharm notebooks, etc.).
tl;dr
To get started right away, install the jupyter-dash
package using pip…
$ pip install jupyter-dash
or conda:
$ conda install -c conda-forge -c plotly jupyter-dash
Then, copy any Dash example into a Jupyter notebook cell and replace the dash.Dash
class with the jupyter_dash.JupyterDash
class. Or, copy and paste this example.
import plotly.express as px
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
# Load Data
df = px.data.tips()
# Build App
app = JupyterDash(__name__)
app.layout = html.Div([
html.H1("JupyterDash Demo"),
dcc.Graph(id='graph'),
html.Label([
"colorscale",
dcc.Dropdown(
id='colorscale-dropdown', clearable=False,
value='plasma', options=[
{'label': c, 'value': c}
for c in px.colors.named_colorscales()
])
]),
])
# Define callback to update graph
@app.callback(
Output('graph', 'figure'),
[Input("colorscale-dropdown", "value")]
)
def update_figure(colorscale):
return px.scatter(
df, x="total_bill", y="tip", color="size",
color_continuous_scale=colorscale,
render_mode="webgl", title="Tips"
)
# Run app and display result inline in the notebook
app.run_server(mode='inline')
You can also try it out, right in your browser, with binder.
Learn More
Check out the full announcement post to learn more, and let us know what you think!
2 posts - 1 participant