Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 096dd00

Browse files
Merge pull request #2161 from plotly/py_shapes_sub_plots
shapes on subplots
2 parents 59cf184 + 3eaa1b3 commit 096dd00

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎doc/python/shapes.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,35 @@ fig.update_layout(
623623
fig.show()
624624
```
625625

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+
626655
#### SVG Paths
627656

628657
```python

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /