Skip to content

Commit 4eed225

Browse files
Merge pull request plotly#3523 from plotly/pre5.52
px-first getting-started/readme
2 parents d281683 + 7aaaaff commit 4eed225

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@
3838
Inside [Jupyter](https://jupyter.org/install) (installable with `pip install "jupyterlab>=3" "ipywidgets>=7.6"`):
3939

4040
```python
41-
import plotly.graph_objects as go
42-
fig = go.Figure()
43-
fig.add_trace(go.Scatter(y=[2, 1, 4, 3]))
44-
fig.add_trace(go.Bar(y=[1, 4, 3, 2]))
45-
fig.update_layout(title = 'Hello Figure')
41+
import plotly.express as px
42+
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
4643
fig.show()
4744
```
4845

doc/python/getting-started.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ This package contains everything you need to write figures to standalone HTML fi
7272
7373

7474
```python
75-
import plotly.graph_objects as go
76-
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
75+
import plotly.express as px
76+
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
7777
fig.write_html('first_figure.html', auto_open=True)
7878
```
7979

@@ -128,17 +128,20 @@ $ jupyter lab
128128
and display plotly figures inline using the `plotly_mimetype` renderer...
129129

130130
```python
131-
import plotly.graph_objects as go
132-
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
131+
import plotly.express as px
132+
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
133133
fig.show()
134134
```
135135

136136
or using `FigureWidget` objects.
137137

138138
```python
139+
import plotly.express as px
140+
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
141+
139142
import plotly.graph_objects as go
140-
fig = go.FigureWidget(data=go.Bar(y=[2, 3, 1]))
141-
fig
143+
fig_widget = go.FigureWidget(fig)
144+
fig_widget
142145
```
143146

144147
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...
180183

181184

182185
```python
183-
import plotly.graph_objects as go
184-
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
186+
import plotly.express as px
187+
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
185188
fig.show()
186189
```
187190

188191
or using `FigureWidget` objects.
189192

190193
```python
194+
import plotly.express as px
195+
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
196+
191197
import plotly.graph_objects as go
192-
fig = go.FigureWidget(data=go.Bar(y=[2, 3, 1]))
193-
fig
198+
fig_widget = go.FigureWidget(fig)
199+
fig_widget
194200
```
195201

196202
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`.

0 commit comments

Comments
 (0)