Skip to content

Commit 95cf2f1

Browse files
Update axes.md
1 parent 1ea0b0d commit 95cf2f1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/python/axes.md

+27
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,33 @@ fig.update_layout(
564564
fig.show()
565565
```
566566

567+
### Fixed Ratio Axes with Compressed domain
568+
569+
If an axis needs to be compressed (either due to its own `scaleanchor` and `scaleratio` or those of the other axis), `constrain` determines how that happens: by increasing the "range" (default), or by decreasing the "domain".
570+
571+
```python
572+
import plotly.graph_objects as go
573+
fig = go.Figure()
574+
fig.add_trace(go.Scatter(
575+
x = [0,1,1,0,0,1,1,2,2,3,3,2,2,3],
576+
y = [0,0,1,1,3,3,2,2,3,3,1,1,0,0]
577+
))
578+
fig.update_layout(
579+
width = 800,
580+
height = 500,
581+
title = "fixed-ratio axes with compressed axes",
582+
xaxis = dict(
583+
range=[-1,4], # sets the range of xaxis
584+
constrain="domain", # meanwhile compresses the xaxis by decreasing its "domain"
585+
),
586+
yaxis = dict(
587+
scaleanchor = "x",
588+
scaleratio = 1,
589+
),
590+
)
591+
fig.show()
592+
```
593+
567594
##### Decreasing the domain spanned by an axis
568595

569596
In the example below, the x and y axis are anchored together, and the range of the `xaxis` is set manually. By default, plotly extends the range of the axis (overriding the `range` parameter) to fit in the figure `domain`. You can restrict the `domain` to force the axis to span only the set range, by setting `constrain='domain'` as below.

0 commit comments

Comments
 (0)