From 26fa4e08ce6fbdeb18c4e8e8c291e02585ebddb0 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Mon, 20 Dec 2021 22:11:03 -0500 Subject: [PATCH] px-first getting-started/readme --- README.md | 7 ++----- doc/python/getting-started.md | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 9a2eb2e471..2d9946e1cf 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,8 @@ Inside [Jupyter](https://jupyter.org/install) (installable with `pip install "jupyterlab>=3" "ipywidgets>=7.6"`): ```python -import plotly.graph_objects as go -fig = go.Figure() -fig.add_trace(go.Scatter(y=[2, 1, 4, 3])) -fig.add_trace(go.Bar(y=[1, 4, 3, 2])) -fig.update_layout(title = 'Hello Figure') +import plotly.express as px +fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) fig.show() ``` diff --git a/doc/python/getting-started.md b/doc/python/getting-started.md index 12c9ec0be1..4d4c871045 100644 --- a/doc/python/getting-started.md +++ b/doc/python/getting-started.md @@ -72,8 +72,8 @@ This package contains everything you need to write figures to standalone HTML fi ```python -import plotly.graph_objects as go -fig = go.Figure(data=go.Bar(y=[2, 3, 1])) +import plotly.express as px +fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) fig.write_html('first_figure.html', auto_open=True) ``` @@ -128,17 +128,20 @@ $ jupyter lab and display plotly figures inline using the `plotly_mimetype` renderer... ```python -import plotly.graph_objects as go -fig = go.Figure(data=go.Bar(y=[2, 3, 1])) +import plotly.express as px +fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) fig.show() ``` or using `FigureWidget` objects. ```python +import plotly.express as px +fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) + import plotly.graph_objects as go -fig = go.FigureWidget(data=go.Bar(y=[2, 3, 1])) -fig +fig_widget = go.FigureWidget(fig) +fig_widget ``` The instructions above apply to JupyterLab 3.x. **For JupyterLab 2 or earlier**, run the following commands to install the required JupyterLab extensions (note that this will require [`node`](https://nodejs.org/) to be installed): @@ -180,17 +183,20 @@ and display plotly figures inline using the notebook renderer... ```python -import plotly.graph_objects as go -fig = go.Figure(data=go.Bar(y=[2, 3, 1])) +import plotly.express as px +fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) fig.show() ``` or using `FigureWidget` objects. ```python +import plotly.express as px +fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) + import plotly.graph_objects as go -fig = go.FigureWidget(data=go.Bar(y=[2, 3, 1])) -fig +fig_widget = go.FigureWidget(fig) +fig_widget ``` See [_Displaying Figures in Python_](/python/renderers/) for more information on the renderers framework, and see [_Plotly FigureWidget Overview_](/python/figurewidget/) for more information on using `FigureWidget`.