Skip to content

Commit 5bf1530

Browse files
authored
Merge pull request #2235 from SylwiaOliwia2/patch-4
Update facet-plots.md
2 parents 235c809 + e9b45bd commit 5bf1530

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: doc/python/facet-plots.md

+21
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,24 @@ fig.show()
118118
```python
119119

120120
```
121+
122+
### Synchronizing axes in subplots with `matches`
123+
124+
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.
125+
126+
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:
127+
128+
```python
129+
import plotly.graph_objects as go
130+
from plotly.subplots import make_subplots
131+
import numpy as np
132+
133+
N = 20
134+
x = np.linspace(0, 1, N)
135+
136+
fig = make_subplots(1, 3)
137+
for i in range(1, 4):
138+
fig.add_trace(go.Scatter(x=x, y=np.random.random(N)), 1, i)
139+
fig.update_xaxes(matches='x')
140+
fig.show()
141+
```

0 commit comments

Comments
 (0)