From cf5bfa069067d4374d5950f16a7151dd83318281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmahdis-z=E2=80=9D?= Date: Tue, 4 Feb 2020 13:54:44 -0500 Subject: [PATCH 1/4] shapes on subplots --- doc/python/shapes.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/python/shapes.md b/doc/python/shapes.md index d0ae16b9e7d..cd7752a6791 100644 --- a/doc/python/shapes.md +++ b/doc/python/shapes.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.1' - jupytext_version: 1.2.1 + format_version: '1.2' + jupytext_version: 1.3.2 kernelspec: display_name: Python 3 language: python @@ -638,6 +638,34 @@ fig.update_layout( fig.show() ``` +#### Adding Shapes to Subplots + +```python +import plotly.graph_objects as go +from plotly.subplots import make_subplots + +# Create Subplots +fig = make_subplots(rows=2, cols=2, start_cell='bottom-left') + +fig.add_trace(go.Scatter(x=[2, 6], y=[1,1]), row=1, col=1) +fig.add_trace(go.Bar(x=[1,2,3], y=[4,5,6]), row=1, col=2) +fig.add_trace(go.Scatter(x=[10,20], y=[40,50]), row=2, col=1) +fig.add_trace(go.Bar(x=[11,13,15], y=[8,11,20]), row=2, col=2) + +# Add shapes +fig.update_layout( + shapes=[ + dict(type="line", xref="x1", yref="y1", + x0=3, y0=0.5, x1=5, y1=0.8), + dict(type="rect", xref="x2", yref='y2', + x0=4, y0=2, x1=5, y1=6), + dict(type="rect", xref="x3", yref="y3", + x0=10, y0=20, x1=15, y1=30), + dict(type="circle", xref="x4", yref="y4", + x0=5, y0=12, x1=10, y1=18)]) +fig.show() +``` + #### SVG Paths ```python From ef82c935853cc44bd6f6579f9d332e6a7318bee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmahdis-z=E2=80=9D?= Date: Wed, 5 Feb 2020 11:00:44 -0500 Subject: [PATCH 2/4] minor revision --- doc/python/shapes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/python/shapes.md b/doc/python/shapes.md index cd7752a6791..ba4eff9aaa8 100644 --- a/doc/python/shapes.md +++ b/doc/python/shapes.md @@ -645,7 +645,7 @@ import plotly.graph_objects as go from plotly.subplots import make_subplots # Create Subplots -fig = make_subplots(rows=2, cols=2, start_cell='bottom-left') +fig = make_subplots(rows=2, cols=2) fig.add_trace(go.Scatter(x=[2, 6], y=[1,1]), row=1, col=1) fig.add_trace(go.Bar(x=[1,2,3], y=[4,5,6]), row=1, col=2) @@ -656,7 +656,7 @@ fig.add_trace(go.Bar(x=[11,13,15], y=[8,11,20]), row=2, col=2) fig.update_layout( shapes=[ dict(type="line", xref="x1", yref="y1", - x0=3, y0=0.5, x1=5, y1=0.8), + x0=3, y0=0.5, x1=5, y1=0.8, line_width=3), dict(type="rect", xref="x2", yref='y2', x0=4, y0=2, x1=5, y1=6), dict(type="rect", xref="x3", yref="y3", From 67a5eaa8bf6ca2e95448179260c4145a720536f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmahdis-z=E2=80=9D?= Date: Wed, 5 Feb 2020 13:49:18 -0500 Subject: [PATCH 3/4] more explanation --- doc/python/shapes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/shapes.md b/doc/python/shapes.md index ba4eff9aaa8..fd0b2e09b0f 100644 --- a/doc/python/shapes.md +++ b/doc/python/shapes.md @@ -639,7 +639,7 @@ fig.show() ``` #### Adding Shapes to Subplots - +Here we use the different axes (`x1`, `x2`) created by `make_subplots` as reference in order to draw shapes in figure subplots. ```python import plotly.graph_objects as go from plotly.subplots import make_subplots From 3eaa1b3c1f985d3972a9bde57644201829b79c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cmahdis-z=E2=80=9D?= Date: Wed, 5 Feb 2020 14:31:25 -0500 Subject: [PATCH 4/4] fix ci failure --- doc/python/shapes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/python/shapes.md b/doc/python/shapes.md index fd0b2e09b0f..e40f62da347 100644 --- a/doc/python/shapes.md +++ b/doc/python/shapes.md @@ -640,6 +640,7 @@ fig.show() #### Adding Shapes to Subplots Here we use the different axes (`x1`, `x2`) created by `make_subplots` as reference in order to draw shapes in figure subplots. + ```python import plotly.graph_objects as go from plotly.subplots import make_subplots