@@ -623,6 +623,35 @@ fig.update_layout(
623
623
fig.show()
624
624
```
625
625
626
+ #### Adding Shapes to Subplots
627
+ Here we use the different axes (` x1 ` , ` x2 ` ) created by ` make_subplots ` as reference in order to draw shapes in figure subplots.
628
+
629
+ ``` python
630
+ import plotly.graph_objects as go
631
+ from plotly.subplots import make_subplots
632
+
633
+ # Create Subplots
634
+ fig = make_subplots(rows = 2 , cols = 2 )
635
+
636
+ fig.add_trace(go.Scatter(x = [2 , 6 ], y = [1 ,1 ]), row = 1 , col = 1 )
637
+ fig.add_trace(go.Bar(x = [1 ,2 ,3 ], y = [4 ,5 ,6 ]), row = 1 , col = 2 )
638
+ fig.add_trace(go.Scatter(x = [10 ,20 ], y = [40 ,50 ]), row = 2 , col = 1 )
639
+ fig.add_trace(go.Bar(x = [11 ,13 ,15 ], y = [8 ,11 ,20 ]), row = 2 , col = 2 )
640
+
641
+ # Add shapes
642
+ fig.update_layout(
643
+ shapes = [
644
+ dict (type = " line" , xref = " x1" , yref = " y1" ,
645
+ x0 = 3 , y0 = 0.5 , x1 = 5 , y1 = 0.8 , line_width = 3 ),
646
+ dict (type = " rect" , xref = " x2" , yref = ' y2' ,
647
+ x0 = 4 , y0 = 2 , x1 = 5 , y1 = 6 ),
648
+ dict (type = " rect" , xref = " x3" , yref = " y3" ,
649
+ x0 = 10 , y0 = 20 , x1 = 15 , y1 = 30 ),
650
+ dict (type = " circle" , xref = " x4" , yref = " y4" ,
651
+ x0 = 5 , y0 = 12 , x1 = 10 , y1 = 18 )])
652
+ fig.show()
653
+ ```
654
+
626
655
#### SVG Paths
627
656
628
657
``` python
0 commit comments