Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit10b0793

Browse files
Merge pull request#173 from plotly/overwrite_flag
documented overwrite argument in update_*
2 parents065ca0e +2a25e1b commit10b0793

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

‎python/creating-and-updating-figures.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension:.md
77
format_name:markdown
88
format_version:'1.1'
9-
jupytext_version:1.1.6
9+
jupytext_version:1.1.1
1010
kernelspec:
1111
display_name:Python 3
1212
language:python
@@ -30,8 +30,8 @@ jupyter:
3030
page_type:example_index
3131
permalink:python/creating-and-updating-figures/
3232
redirect_from:
33-
-python/user-guide/
34-
-python/user-g/
33+
-python/user-guide/
34+
-python/user-g/
3535
thumbnail:thumbnail/creating-and-updating-figures.png
3636
---
3737

@@ -436,6 +436,23 @@ fig.update_traces(
436436
fig.show()
437437
```
438438

439+
###Overwrite existing properties when using update methods
440+
441+
`update_layout` and`update_traces` have an`overwrite` keyword argument, defaulting to False, in which case updates are applied recursively to the*existing* nested property structure. When set to True, the prior value of existing properties is overwritten with the provided value.
442+
443+
In the example below, the red color of markers is overwritten when updating`marker` in`update_traces` with`overwrite=True`. Note that setting instead`marker_opacity` with the magic underscore would not overwrite`marker_color` because properties would be overwritten starting only at the level of`marker.opacity`.
444+
445+
```python
446+
import plotly.graph_objectsas go
447+
fig= go.Figure(go.Bar(x=[1,2,3],y=[6,4,9],
448+
marker_color="red"))# will be overwritten below
449+
fig.update_traces(
450+
overwrite=True,
451+
marker={"opacity":0.4}
452+
)
453+
fig.show()
454+
```
455+
439456
####The for each trace method
440457
Suppose the updates that you want to make to a collection of traces depend on the current values of certain trace properties. The`update_traces` method cannot handle this situation, but the`for_each_trace` method can.
441458

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp