Skip to content

Commit 3f7b28d

Browse files
SylwiaOliwia2nicolaskruchten
authored andcommitted
Update facet-plots.md
Added section 'Zooming subplots to the same range'
1 parent ba31e77 commit 3f7b28d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

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

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

0 commit comments

Comments
 (0)