From 2a5b53ec719f33497755aaef9b00c72d9bf1cd20 Mon Sep 17 00:00:00 2001 From: Sylwia Mielnicka Date: Thu, 27 Feb 2020 10:09:44 +0100 Subject: [PATCH 1/3] Update facet-plots.md Added section 'Zooming subplots to the same range' --- doc/python/facet-plots.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/python/facet-plots.md b/doc/python/facet-plots.md index 999a23fd0e3..98379acedc0 100644 --- a/doc/python/facet-plots.md +++ b/doc/python/facet-plots.md @@ -118,3 +118,20 @@ fig.show() ```python ``` + +### Zooming subplots to the same range + +Using `facet_col` from `plotly.express` let zoom each facet to the same range impliciltly. However, if the subplots are created with `make_subplots`, the axis needs to be updated with `matches` parameter to zoom all the subplots accordingly. Zoom in one trace below, to see the other subplots zoomed to the same x-axis range: + +```python +import plotly.graph_objects as go +from plotly.subplots import make_subplots +import numpy as np +N = 20 +x = np.linspace(0, 1, N) +fig = make_subplots(1, 3) +for i in range(1, 4): + fig.add_trace(go.Scatter(x=x, y=np.random.random(N)), 1, i) +fig.update_xaxes(matches='x') +fig.show() +``` From 0d4fcc6a4f71f2db0d2c8c42b50caf9742fab8b7 Mon Sep 17 00:00:00 2001 From: Sylwia Mielnicka Date: Tue, 3 Mar 2020 05:57:30 +0100 Subject: [PATCH 2/3] Update doc/python/facet-plots.md Fix Typo Co-Authored-By: Emmanuelle Gouillart --- doc/python/facet-plots.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python/facet-plots.md b/doc/python/facet-plots.md index 98379acedc0..ee3c5a3ae8f 100644 --- a/doc/python/facet-plots.md +++ b/doc/python/facet-plots.md @@ -121,7 +121,7 @@ fig.show() ### Zooming subplots to the same range -Using `facet_col` from `plotly.express` let zoom each facet to the same range impliciltly. However, if the subplots are created with `make_subplots`, the axis needs to be updated with `matches` parameter to zoom all the subplots accordingly. Zoom in one trace below, to see the other subplots zoomed to the same x-axis range: +Using `facet_col` from `plotly.express` let zoom each facet to the same range implicitly. However, if the subplots are created with `make_subplots`, the axis needs to be updated with `matches` parameter to zoom all the subplots accordingly. Zoom in one trace below, to see the other subplots zoomed to the same x-axis range: ```python import plotly.graph_objects as go From e9b45bd1a529b045b140511a748631f96b9b2519 Mon Sep 17 00:00:00 2001 From: Sylwia Mielnicka Date: Tue, 3 Mar 2020 06:17:30 +0100 Subject: [PATCH 3/3] Update facet-plots.md Update 'Synchronizing axes in subplots with matches' title; mention pan in this section. --- doc/python/facet-plots.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/python/facet-plots.md b/doc/python/facet-plots.md index ee3c5a3ae8f..6df50ae549a 100644 --- a/doc/python/facet-plots.md +++ b/doc/python/facet-plots.md @@ -119,16 +119,20 @@ fig.show() ``` -### Zooming subplots to the same range +### Synchronizing axes in subplots with `matches` -Using `facet_col` from `plotly.express` let zoom each facet to the same range implicitly. However, if the subplots are created with `make_subplots`, the axis needs to be updated with `matches` parameter to zoom all the subplots accordingly. Zoom in one trace below, to see the other subplots zoomed to the same x-axis range: +Using `facet_col` from `plotly.express` let [zoom](https://help.plot.ly/zoom-pan-hover-controls/#step-3-zoom-in-and-zoom-out-autoscale-the-plot) and [pan](https://help.plot.ly/zoom-pan-hover-controls/#step-6-pan-along-axes) each facet to the same range implicitly. However, if the subplots are created with `make_subplots`, the axis needs to be updated with `matches` parameter to update all the subplots accordingly. + +Zoom in one trace below, to see the other subplots zoomed to the same x-axis range. To pan all the subplots, click and drag from the center of x-axis to the side: ```python import plotly.graph_objects as go from plotly.subplots import make_subplots import numpy as np + N = 20 x = np.linspace(0, 1, N) + fig = make_subplots(1, 3) for i in range(1, 4): fig.add_trace(go.Scatter(x=x, y=np.random.random(N)), 1, i)