Skip to content

Commit 7151708

Browse files
committed
magic underscore notation and notes
1 parent 47e7ba5 commit 7151708

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

notebooks/templates.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Here is an example that creates a template that sets the default title font to s
125125
import plotly.graph_objects as go
126126

127127
large_rockwell_template = go.layout.Template(
128-
layout=go.Layout(dict(title=dict(font=dict(family="Rockwell", size=24))))
128+
layout=go.Layout(title_font=dict(family="Rockwell", size=24))
129129
)
130130

131131
fig = go.Figure()
@@ -134,6 +134,8 @@ fig.update_layout(title="Figure Title",
134134
fig.show()
135135
```
136136

137+
> Note: this example uses magic underscore notation to write `go.Layout(title=dict(font=dict(...)))` as `go.Layout(title_font=dict(...))`
138+
137139
### The template data property
138140
The `data` property of a template is used to customize the default values of the properties of traces that are added to a figure that the template is applied to. This `data` property holds a graph object, with type `go.layout.template.Data`, that has a property named after each supported trace type. These trace type properties are then assigned lists or tuples of graph object traces of the corresponding type.
139141

@@ -297,6 +299,8 @@ fig.update_layout(template="draft")
297299
fig.show()
298300
```
299301

302+
> Note: this example uses magic underscore notation to write `go.layout.Template(layout=dict(annotations=[...]))` as ``go.layout.Template(layout_annotations=[...])`
303+
300304
It is also possible to set your own custom template as the default so that you do not need to pass it by name when constructing graph object figures or calling plotly express functions.
301305

302306
```python

0 commit comments

Comments
 (0)