@@ -53,7 +53,7 @@ import plotly.graph_objects as go
53
53
54
54
fig = go.Figure()
55
55
56
- config = dict ( {' scrollZoom' : True })
56
+ config = {' scrollZoom' : True }
57
57
58
58
fig.add_trace(
59
59
go.Scatter(
@@ -244,6 +244,8 @@ fig.add_trace(
244
244
y = [1 , 3 , 1 ]))
245
245
246
246
fig.update_layout(modebar_remove = [' zoom' , ' pan' ])
247
+
248
+ fig.show()
247
249
```
248
250
249
251
### Add optional shape-drawing buttons to modebar
@@ -253,16 +255,19 @@ fig.update_layout(modebar_remove=['zoom', 'pan'])
253
255
Some modebar buttons of Cartesian plots are optional and have to be added explicitly, using the ` modeBarButtonsToAdd ` config attribute. These buttons are used for drawing or erasing shapes. See [ the tutorial on shapes and shape drawing] ( python/shapes#drawing-shapes-on-cartesian-plots ) for more details.
254
256
255
257
``` python
256
- import plotly.graph_objects as go
257
258
import plotly.express as px
259
+
258
260
df = px.data.iris()
261
+
259
262
fig = px.scatter(df, x = ' petal_width' , y = ' sepal_length' , color = ' species' )
263
+
260
264
fig.update_layout(
261
265
dragmode = ' drawopenpath' ,
262
266
newshape_line_color = ' cyan' ,
263
267
title_text = ' Draw a path to separate versicolor and virginica'
264
268
)
265
- fig.show(config = {' modeBarButtonsToAdd' :[' drawline' ,
269
+
270
+ fig.show(config = {' modeBarButtonsToAdd' : [' drawline' ,
266
271
' drawopenpath' ,
267
272
' drawclosedpath' ,
268
273
' drawcircle' ,
@@ -276,10 +281,12 @@ fig.show(config={'modeBarButtonsToAdd':['drawline',
276
281
The ` layout.modebar.add ` attribute can be used instead of the approach used above:
277
282
278
283
``` python
279
- import plotly.graph_objects as go
280
284
import plotly.express as px
285
+
281
286
df = px.data.iris()
287
+
282
288
fig = px.scatter(df, x = ' petal_width' , y = ' sepal_length' , color = ' species' )
289
+
283
290
fig.update_layout(
284
291
dragmode = ' drawopenpath' ,
285
292
newshape_line_color = ' cyan' ,
@@ -292,6 +299,8 @@ fig.update_layout(
292
299
' eraseshape'
293
300
]
294
301
)
302
+
303
+ fig.show()
295
304
```
296
305
297
306
### Double-Click Delay
@@ -304,12 +313,12 @@ import plotly.graph_objects as go
304
313
config = {' doubleClickDelay' : 1000 }
305
314
306
315
fig = go.Figure(go.Bar(
307
- y = [3 , 5 , 3 , 2 ],
308
- x = [" 2019-09-02" , " 2019-10-10" , " 2019-11-12" , " 2019-12-22" ],
309
- texttemplate = " %{label} " ,
310
- textposition = " inside" ))
316
+ y = [3 , 5 , 3 , 2 ],
317
+ x = [" 2019-09-02" , " 2019-10-10" , " 2019-11-12" , " 2019-12-22" ],
318
+ texttemplate = " %{label} " ,
319
+ textposition = " inside" ))
311
320
312
- fig.update_layout(xaxis = {' type' : ' date' })
321
+ fig.update_layout(xaxis = {' type' : ' date' })
313
322
314
323
fig.show(config = config)
315
324
```
@@ -320,4 +329,4 @@ The same configuration dictionary that you pass to the `config` parameter of the
320
329
321
330
#### Reference
322
331
323
- See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L6
332
+ See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js
0 commit comments