Skip to content

Commit cd630f2

Browse files
committed
new examples
1 parent 190a9c7 commit cd630f2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

plotly/widgets/graph_widget.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,44 @@ def extend_traces(self, update, indices=(0,), max_points=None):
764764
}
765765
)
766766
```
767+
768+
Example 6 - Update other attributes, like marker colors and
769+
sizes and text
770+
```
771+
# Initialize a plot with some empty attributes
772+
graph.plot([{
773+
'x': [],
774+
'y': [],
775+
'text': [],
776+
'marker': {
777+
'size': [],
778+
'color': []
779+
}
780+
}])
781+
# Append some data into those attributes
782+
graph.extend_traces({
783+
'x': [[1, 2, 3]],
784+
'y': [[10, 20, 30]],
785+
'text': [['A', 'B', 'C']],
786+
'marker.size': [[10, 15, 20]],
787+
'marker.color': [['blue', 'red', 'orange']]
788+
}, indices=[0])
789+
```
790+
791+
Example 7 - Live-update a graph over a few seconds
792+
```
793+
import time
794+
795+
graph.plot([{'x': [], 'y': []}])
796+
for i in range(10):
797+
graph.extend_traces({
798+
'x': [[i]],
799+
'y': [[i]]
800+
}, indices=[0])
801+
802+
time.sleep(0.5)
803+
```
804+
767805
"""
768806
message = {
769807
'task': 'extendTraces',

0 commit comments

Comments
 (0)