Skip to content

Commit cf5bfa0

Browse files
author
“mahdis-z”
committed
shapes on subplots
1 parent 2a9aafd commit cf5bfa0

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

doc/python/shapes.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.1'
9-
jupytext_version: 1.2.1
8+
format_version: '1.2'
9+
jupytext_version: 1.3.2
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -638,6 +638,34 @@ fig.update_layout(
638638
fig.show()
639639
```
640640

641+
#### Adding Shapes to Subplots
642+
643+
```python
644+
import plotly.graph_objects as go
645+
from plotly.subplots import make_subplots
646+
647+
# Create Subplots
648+
fig = make_subplots(rows=2, cols=2, start_cell='bottom-left')
649+
650+
fig.add_trace(go.Scatter(x=[2, 6], y=[1,1]), row=1, col=1)
651+
fig.add_trace(go.Bar(x=[1,2,3], y=[4,5,6]), row=1, col=2)
652+
fig.add_trace(go.Scatter(x=[10,20], y=[40,50]), row=2, col=1)
653+
fig.add_trace(go.Bar(x=[11,13,15], y=[8,11,20]), row=2, col=2)
654+
655+
# Add shapes
656+
fig.update_layout(
657+
shapes=[
658+
dict(type="line", xref="x1", yref="y1",
659+
x0=3, y0=0.5, x1=5, y1=0.8),
660+
dict(type="rect", xref="x2", yref='y2',
661+
x0=4, y0=2, x1=5, y1=6),
662+
dict(type="rect", xref="x3", yref="y3",
663+
x0=10, y0=20, x1=15, y1=30),
664+
dict(type="circle", xref="x4", yref="y4",
665+
x0=5, y0=12, x1=10, y1=18)])
666+
fig.show()
667+
```
668+
641669
#### SVG Paths
642670

643671
```python

0 commit comments

Comments
 (0)