@@ -458,8 +458,9 @@ def update(self, dict1=None, overwrite=False, **kwargs):
458
458
--------
459
459
>>> import plotly.graph_objs as go
460
460
>>> fig = go.Figure(data=[{'y': [1, 2, 3]}])
461
- >>> fig.update(data=[{'y': [4, 5, 6]}])
462
- >>> fig.to_plotly_json()
461
+ >>> fig.update(data=[{'y': [4, 5, 6]}]) # doctest: +ELLIPSIS
462
+ Figure(...)
463
+ >>> fig.to_plotly_json() # doctest: +SKIP
463
464
{'data': [{'type': 'scatter',
464
465
'uid': 'e86a7c7a-346a-11e8-8aa8-a0999b0c017b',
465
466
'y': array([4, 5, 6], dtype=int32)}],
@@ -468,8 +469,9 @@ def update(self, dict1=None, overwrite=False, **kwargs):
468
469
>>> fig = go.Figure(layout={'xaxis':
469
470
... {'color': 'green',
470
471
... 'range': [0, 1]}})
471
- >>> fig.update({'layout': {'xaxis': {'color': 'pink'}}})
472
- >>> fig.to_plotly_json()
472
+ >>> fig.update({'layout': {'xaxis': {'color': 'pink'}}}) # doctest: +ELLIPSIS
473
+ Figure(...)
474
+ >>> fig.to_plotly_json() # doctest: +SKIP
473
475
{'data': [],
474
476
'layout': {'xaxis':
475
477
{'color': 'pink',
@@ -1128,6 +1130,8 @@ def plotly_restyle(self, restyle_data, trace_indexes=None, **kwargs):
1128
1130
example, the following command would be used to update the 'x'
1129
1131
property of the first trace to the list [1, 2, 3]
1130
1132
1133
+ >>> import plotly.graph_objects as go
1134
+ >>> fig = go.Figure(go.Scatter(x=[2, 4, 6]))
1131
1135
>>> fig.plotly_restyle({'x': [[1, 2, 3]]}, 0)
1132
1136
1133
1137
trace_indexes : int or list of int
@@ -1586,15 +1590,19 @@ def add_trace(self, trace, row=None, col=None, secondary_y=None):
1586
1590
Add two Scatter traces to a figure
1587
1591
1588
1592
>>> fig = go.Figure()
1589
- >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2]))
1590
- >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2]))
1593
+ >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2])) # doctest: +ELLIPSIS
1594
+ Figure(...)
1595
+ >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2])) # doctest: +ELLIPSIS
1596
+ Figure(...)
1591
1597
1592
1598
1593
1599
Add two Scatter traces to vertically stacked subplots
1594
1600
1595
1601
>>> fig = subplots.make_subplots(rows=2)
1596
- >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2]), row=1, col=1)
1597
- >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2]), row=2, col=1)
1602
+ >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2]), row=1, col=1) # doctest: +ELLIPSIS
1603
+ Figure(...)
1604
+ >>> fig.add_trace(go.Scatter(x=[1,2,3], y=[2,1,2]), row=2, col=1) # doctest: +ELLIPSIS
1605
+ Figure(...)
1598
1606
"""
1599
1607
# Make sure we have both row and col or neither
1600
1608
if row is not None and col is None :
@@ -1662,14 +1670,16 @@ def add_traces(self, data, rows=None, cols=None, secondary_ys=None):
1662
1670
1663
1671
>>> fig = go.Figure()
1664
1672
>>> fig.add_traces([go.Scatter(x=[1,2,3], y=[2,1,2]),
1665
- ... go.Scatter(x=[1,2,3], y=[2,1,2])])
1673
+ ... go.Scatter(x=[1,2,3], y=[2,1,2])]) # doctest: +ELLIPSIS
1674
+ Figure(...)
1666
1675
1667
1676
Add two Scatter traces to vertically stacked subplots
1668
1677
1669
1678
>>> fig = subplots.make_subplots(rows=2)
1670
1679
>>> fig.add_traces([go.Scatter(x=[1,2,3], y=[2,1,2]),
1671
1680
... go.Scatter(x=[1,2,3], y=[2,1,2])],
1672
- ... rows=[1, 2], cols=[1, 1])
1681
+ ... rows=[1, 2], cols=[1, 1]) # doctest: +ELLIPSIS
1682
+ Figure(...)
1673
1683
"""
1674
1684
1675
1685
# Validate traces
@@ -2152,11 +2162,12 @@ def _build_dispatch_plan(key_path_strs):
2152
2162
2153
2163
Examples
2154
2164
--------
2165
+
2155
2166
>>> key_path_strs = ['xaxis.rangeselector.font.color',
2156
2167
... 'xaxis.rangeselector.bgcolor']
2157
2168
2158
- >>> BaseFigure._build_dispatch_plan(key_path_strs)
2159
- {(): {( 'xaxis',) ,
2169
+ >>> BaseFigure._build_dispatch_plan(key_path_strs) # doctest: +SKIP
2170
+ {(): {'xaxis',
2160
2171
('xaxis', 'rangeselector'),
2161
2172
('xaxis', 'rangeselector', 'bgcolor'),
2162
2173
('xaxis', 'rangeselector', 'font'),
@@ -2589,7 +2600,7 @@ def batch_animate(self, duration=500, easing="cubic-in-out"):
2589
2600
2) Animate a change in the size and color of the trace's markers
2590
2601
over 2 seconds using the elastic-in-out easing method
2591
2602
2592
- >>> with fig.batch_update (duration=2000, easing='elastic-in-out'):
2603
+ >>> with fig.batch_animate (duration=2000, easing='elastic-in-out'):
2593
2604
... fig.data[0].marker.color = 'green'
2594
2605
... fig.data[0].marker.size = 20
2595
2606
"""
@@ -4088,6 +4099,8 @@ def on_change(self, callback, *args, **kwargs):
4088
4099
Register callback that prints out the range extents of the xaxis and
4089
4100
yaxis whenever either either of them changes.
4090
4101
4102
+ >>> import plotly.graph_objects as go
4103
+ >>> fig = go.Figure(go.Scatter(x=[1, 2], y=[1, 0]))
4091
4104
>>> fig.layout.on_change(
4092
4105
... lambda obj, xrange, yrange: print("%s-%s" % (xrange, yrange)),
4093
4106
... ('xaxis', 'range'), ('yaxis', 'range'))
@@ -4572,13 +4585,15 @@ def on_hover(self, callback, append=False):
4572
4585
Examples
4573
4586
--------
4574
4587
4588
+ >>> import plotly.graph_objects as go
4575
4589
>>> from plotly.callbacks import Points, InputDeviceState
4576
4590
>>> points, state = Points(), InputDeviceState()
4577
4591
4578
4592
>>> def hover_fn(trace, points, state):
4579
4593
... inds = points.point_inds
4580
4594
... # Do something
4581
4595
4596
+ >>> trace = go.Scatter(x=[1, 2], y=[3, 0])
4582
4597
>>> trace.on_hover(hover_fn)
4583
4598
4584
4599
Note: The creation of the `points` and `state` objects is optional,
@@ -4632,13 +4647,15 @@ def on_unhover(self, callback, append=False):
4632
4647
Examples
4633
4648
--------
4634
4649
4650
+ >>> import plotly.graph_objects as go
4635
4651
>>> from plotly.callbacks import Points, InputDeviceState
4636
4652
>>> points, state = Points(), InputDeviceState()
4637
4653
4638
4654
>>> def unhover_fn(trace, points, state):
4639
4655
... inds = points.point_inds
4640
4656
... # Do something
4641
4657
4658
+ >>> trace = go.Scatter(x=[1, 2], y=[3, 0])
4642
4659
>>> trace.on_unhover(unhover_fn)
4643
4660
4644
4661
Note: The creation of the `points` and `state` objects is optional,
@@ -4692,13 +4709,15 @@ def on_click(self, callback, append=False):
4692
4709
Examples
4693
4710
--------
4694
4711
4712
+ >>> import plotly.graph_objects as go
4695
4713
>>> from plotly.callbacks import Points, InputDeviceState
4696
4714
>>> points, state = Points(), InputDeviceState()
4697
4715
4698
4716
>>> def click_fn(trace, points, state):
4699
4717
... inds = points.point_inds
4700
4718
... # Do something
4701
4719
4720
+ >>> trace = go.Scatter(x=[1, 2], y=[3, 0])
4702
4721
>>> trace.on_click(click_fn)
4703
4722
4704
4723
Note: The creation of the `points` and `state` objects is optional,
@@ -4751,13 +4770,15 @@ def on_selection(self, callback, append=False):
4751
4770
Examples
4752
4771
--------
4753
4772
4773
+ >>> import plotly.graph_objects as go
4754
4774
>>> from plotly.callbacks import Points
4755
4775
>>> points = Points()
4756
4776
4757
4777
>>> def selection_fn(trace, points, selector):
4758
4778
... inds = points.point_inds
4759
4779
... # Do something
4760
4780
4781
+ >>> trace = go.Scatter(x=[1, 2], y=[3, 0])
4761
4782
>>> trace.on_selection(selection_fn)
4762
4783
4763
4784
Note: The creation of the `points` object is optional,
@@ -4817,13 +4838,15 @@ def on_deselect(self, callback, append=False):
4817
4838
Examples
4818
4839
--------
4819
4840
4841
+ >>> import plotly.graph_objects as go
4820
4842
>>> from plotly.callbacks import Points
4821
4843
>>> points = Points()
4822
4844
4823
4845
>>> def deselect_fn(trace, points):
4824
4846
... inds = points.point_inds
4825
4847
... # Do something
4826
4848
4849
+ >>> trace = go.Scatter(x=[1, 2], y=[3, 0])
4827
4850
>>> trace.on_deselect(deselect_fn)
4828
4851
4829
4852
Note: The creation of the `points` object is optional,
0 commit comments