Skip to content

Commit ba31e77

Browse files
SylwiaOliwia2nicolaskruchten
authored andcommitted
Update axes.md
Added section 'Zooming subplots to the same range'
1 parent 4ec6ad1 commit ba31e77

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: doc/python/axes.md

+21
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,27 @@ fig.update_yaxes(domain=(0.25, 0.75))
741741
fig.show()
742742
```
743743

744+
### Zooming subplots to the same range
745+
746+
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:
747+
748+
```python
749+
import plotly.graph_objects as go
750+
from plotly.subplots import make_subplots
751+
import numpy as np
752+
753+
N = 20
754+
x = np.linspace(0, 1, N)
755+
756+
fig = make_subplots(1, 3)
757+
758+
for i in range(1, 4):
759+
fig.add_trace(go.Scatter(x=x, y=np.random.random(N)), 1, i)
760+
761+
fig.update_xaxes(matches='x')
762+
fig.show()
763+
```
764+
744765
#### Reference
745766

746767
See https://plot.ly/python/reference/#layout-xaxis and https://plot.ly/python/reference/#layout-yaxis for more information and chart attribute options!

0 commit comments

Comments
 (0)