Skip to content

Commit 58a9154

Browse files
committed
Move property assignment to the end
1 parent 9147f27 commit 58a9154

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

notebooks/creating-updating-figures.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -227,26 +227,6 @@ fig.show()
227227

228228
Magic underscore notation is supported throughout the graph objects API, and it can often significantly simplify operations involving deeply nested properties.
229229

230-
### Property assignment
231-
Trace and layout properties can be updated using property assignment syntax. Here is an example of setting the figure title using property assignment.
232-
233-
```python
234-
import plotly.graph_objects as go
235-
fig = go.Figure(data=go.Bar(x=[1, 2, 3], y=[1, 3, 2]))
236-
fig.layout.title.text = "A Bar Chart"
237-
fig.show()
238-
```
239-
240-
And here is an example of updating the bar outline using property assignment
241-
242-
```python
243-
import plotly.graph_objects as go
244-
fig = go.Figure(data=go.Bar(x=[1, 2, 3], y=[1, 3, 2]))
245-
fig.data[0].marker.line.width = 4
246-
fig.data[0].marker.line.color = "black"
247-
fig.show()
248-
```
249-
250230
### The update layout method
251231
Graph object figures support an `update_layout` method that may be used to update multiple nested properties of a figure's layout. Here is an example of updating the text and font size of a figure's title using `update_layout`.
252232

@@ -466,7 +446,7 @@ There are also `for_each_xaxis` and `for_each_yaxis` methods that are analogous
466446

467447

468448
### Chaining figure operations
469-
With the exception of property assignment, all of the figure update operations described in this section are methods that return a reference to the figure being modified. This makes it possible the chain multiple figure modification operations together into a single expression.
449+
All of the figure update operations described above are methods that return a reference to the figure being modified. This makes it possible the chain multiple figure modification operations together into a single expression.
470450

471451
Here is an example of a chained expression that creates a faceted scatter plot with OLS trend lines using plotly express, sets the title font size using `update_layout`, disables vertical grid lines using `update_xaxes`, updates the width and dash pattern of the trend lines using `update_traces`, and then displays the figure using `show`.
472452

@@ -482,3 +462,23 @@ iris = px.data.iris()
482462
selector=dict(type="scatter", mode="lines"))
483463
).show()
484464
```
465+
466+
### Property assignment
467+
Trace and layout properties can be updated using property assignment syntax. Here is an example of setting the figure title using property assignment.
468+
469+
```python
470+
import plotly.graph_objects as go
471+
fig = go.Figure(data=go.Bar(x=[1, 2, 3], y=[1, 3, 2]))
472+
fig.layout.title.text = "A Bar Chart"
473+
fig.show()
474+
```
475+
476+
And here is an example of updating the bar outline using property assignment
477+
478+
```python
479+
import plotly.graph_objects as go
480+
fig = go.Figure(data=go.Bar(x=[1, 2, 3], y=[1, 3, 2]))
481+
fig.data[0].marker.line.width = 4
482+
fig.data[0].marker.line.color = "black"
483+
fig.show()
484+
```

0 commit comments

Comments
 (0)