From 26fa4e08ce6fbdeb18c4e8e8c291e02585ebddb0 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Mon, 20 Dec 2021 22:11:03 -0500 Subject: [PATCH 1/2] 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 9a2eb2e4714..2d9946e1cfc 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 12c9ec0be1d..4d4c871045f 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`. From 7aaaaff4857898d126f4d17f24c6b271a1692602 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Mon, 20 Dec 2021 22:11:57 -0500 Subject: [PATCH 2/2] format --- README.md | 2 +- doc/python/getting-started.md | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2d9946e1cfc..17e186775b7 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Inside [Jupyter](https://jupyter.org/install) (installable with `pip install "ju ```python import plotly.express as px -fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) +fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.show() ``` diff --git a/doc/python/getting-started.md b/doc/python/getting-started.md index 4d4c871045f..42f78f64674 100644 --- a/doc/python/getting-started.md +++ b/doc/python/getting-started.md @@ -73,7 +73,7 @@ This package contains everything you need to write figures to standalone HTML fi ```python import plotly.express as px -fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) +fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.write_html('first_figure.html', auto_open=True) ``` @@ -129,7 +129,7 @@ and display plotly figures inline using the `plotly_mimetype` renderer... ```python import plotly.express as px -fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) +fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.show() ``` @@ -137,7 +137,7 @@ or using `FigureWidget` objects. ```python import plotly.express as px -fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) +fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) import plotly.graph_objects as go fig_widget = go.FigureWidget(fig) @@ -184,7 +184,7 @@ and display plotly figures inline using the notebook renderer... ```python import plotly.express as px -fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) +fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.show() ``` @@ -192,7 +192,7 @@ or using `FigureWidget` objects. ```python import plotly.express as px -fig = px.bar(x=["a", "b", "c"], y=[1,2,3]) +fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) import plotly.graph_objects as go fig_widget = go.FigureWidget(fig)