语法

``linkaxes(ax)``
``linkaxes(ax,dimension)``

说明

``linkaxes(ax)` 同步指定的坐标区向量的范围。同步范围允许您在一个绘图或图窗中缩放或平移，并在另一个绘图或图窗中显示相同的数据范围。当您第一次调用 `linkaxes` 时，该函数选择的新范围涵盖所有指定坐标区的当前范围。 `

``linkaxes(ax,dimension)` 同步指定坐标区维度的坐标区范围。例如，`linkaxes(ax,'x')` 仅同步 x 轴的范围。`

示例

```tiledlayout(3,1) % First plot ax1 = nexttile; x1 = linspace(0,6); y1 = sin(x1); plot(x1,y1) % Second plot ax2 = nexttile; x2 = linspace(0,10); y2 = 2*sin(2*x2); plot(x2,y2) % Third plot ax3 = nexttile; x3 = linspace(0,12,200); y3 = 4*sin(6*x3); plot(x3,y3)```

`linkaxes([ax1 ax2 ax3],'xy')`

`ax1.XLim = [0 4.5];`

```t = tiledlayout(2,1); % First plot ax1 = nexttile; p1 = peaks; surf(ax1,p1); view(3) % Second plot ax2 = nexttile; p2 = peaks(25); mesh(ax2,p2)```

`linkaxes([ax1 ax2],'x');`

```ax1.XLim = [0 15]; ax2.XLim```
```ans = 1×2 0 15 ```

`linkaxes([ax1 ax2],'off');`

```London = datetime(2021,1,1,0:17,0,0,"TimeZone","Europe/London"); y = (1./(1:18).^2) * 100000; ax1 = nexttile; semilogy(ax1,London,y) grid on title("New Year's Day Revelers in London")```

```NY = datetime(2021,1,1,0:17,0,0,"TimeZone","America/New_York"); ax2 = nexttile; semilogy(ax2,NY,y) grid on title("New Year's Day Revelers in New York")```

```ax2.XAxis.ReferenceDate = datetime(2022,1,1,"TimeZone","Europe/London"); linkaxes([ax1,ax2],"x")```

输入参数

• `'xyz'` - 同步 x 轴、y 轴和 z 轴范围。

• `'x'` - 仅同步 x 轴范围。

• `'y'` - 仅同步 y 轴范围。

• `'z'` - 仅同步 z 轴范围。

• `'xy'` - 仅同步 x 轴和 y 轴范围。

• `'xz'` - 仅同步 x 轴和 z 轴范围。

• `'yz'` - 仅同步 y 轴和 z 轴范围。

• `'off'` - 关闭同步。