@@ -307,60 +307,6 @@ fig.update_layout(
307
307
fig.show()
308
308
```
309
309
310
- ### Waterfall Bar Chart
311
-
312
- ``` python
313
- import plotly.graph_objects as go
314
-
315
- x_data = [' Product<br>Revenue' , ' Services<br>Revenue' ,
316
- ' Total<br>Revenue' , ' Fixed<br>Costs' ,
317
- ' Variable<br>Costs' , ' Total<br>Costs' , ' Total' ]
318
- y_data = [400 , 660 , 660 , 590 , 400 , 400 , 340 ]
319
- text = [' $430K' , ' $260K' , ' $690K' , ' $-120K' , ' $-200K' , ' $-320K' , ' $370K' ]
320
-
321
- fig = go.Figure()
322
- # Base
323
- fig.add_trace(go.Bar(x = x_data,
324
- y = [0 , 430 , 0 , 570 , 370 , 370 , 0 ],
325
- marker_color = ' rgba(1,1,1, 0.0)' ))
326
- # Revenue
327
- fig.add_trace(go.Bar(x = x_data,
328
- y = [430 , 260 , 690 , 0 , 0 , 0 , 0 ],
329
- marker_color = ' rgba(55, 128, 191, 0.7)' ,
330
- marker_line_color = ' rgba(55, 128, 191, 1.0)'
331
- ))
332
- # Costs
333
- fig.add_trace(go.Bar(x = x_data,
334
- y = [0 , 0 , 0 , 120 , 200 , 320 , 0 ],
335
- marker_color = ' rgba(219, 64, 82, 0.7)' ,
336
- marker_line_color = ' rgba(219, 64, 82, 1.0)' ,
337
- ))
338
- # Profit
339
- fig.add_trace(go.Bar(x = x_data,
340
- y = [0 , 0 , 0 , 0 , 0 , 0 , 370 ],
341
- marker_color = ' rgba(50, 171, 96, 0.7)' ,
342
- marker_line_color = ' rgba(50, 171, 96, 1.0)'
343
- ))
344
-
345
- annotations = []
346
-
347
- for i in range (0 , 7 ):
348
- annotations.append(dict (x = x_data[i], y = y_data[i], text = text[i],
349
- font = dict (family = ' Arial' , size = 14 ,
350
- color = ' rgba(245, 246, 249, 1)' ),
351
- showarrow = False ,))
352
-
353
- fig.update_layout(annotations = annotations,
354
- title = ' Annual Profit- 2015' ,
355
- barmode = ' stack' ,
356
- paper_bgcolor = ' rgba(245, 246, 249, 1)' ,
357
- plot_bgcolor = ' rgba(245, 246, 249, 1)' ,
358
- showlegend = False )
359
-
360
- fig.update_traces(marker_line_width = 2 )
361
- fig.show()
362
- ```
363
-
364
310
### Bar Chart with Relative Barmode
365
311
366
312
With "relative" barmode, the bars are stacked on top of one another, with negative values
0 commit comments