主要内容

zscale

设置或查询 z 轴刻度(线性或对数)

自 R2023b 起

    说明

    zscale(scale)z 轴的刻度设置为当前坐标区中的线性或对数刻度。将 scale 指定为 "linear""log"。使用此语法时,也可以省略括号和引号。例如,zscale log 等同于 zscale("log")

    示例

    zscale(ax,___) 设置指定坐标区对象的刻度。当您在分块图布局或不同图窗中处理多个图时,此语法非常有用。

    示例

    zs = zscale'linear''log' 形式返回当前 z 轴刻度值。

    示例

    全部折叠

    创建矩阵 X、Y 和 Z,并使用它们创建一个曲面图。

    [X,Y] = meshgrid(0:1:100);
    Z = X.*Y;
    surf(X,Y,Z,EdgeColor="none")
    view(-145,10)

    Figure contains an axes object. The axes object contains an object of type surface.

    z 轴的刻度更改为对数。

    zscale log

    Figure contains an axes object. The axes object contains an object of type surface.

    在一个分块图布局中两次创建相同的曲面图。以下代码调用 nexttile 函数来创建具有一个坐标区对象的分块图布局。对 nexttile 的第二次调用会创建并返回第二个坐标区对象。

    [X,Y] = meshgrid(0:1:100);
    Z = X.*Y;
    
    nexttile;
    surf(X,Y,Z,EdgeColor="none")
    view(-145,10)
    title("Linear Scale")
    
    ax2 = nexttile;
    surf(X,Y,Z,EdgeColor="none")
    view(-145,10)
    title("Log Scale")

    Figure contains 2 axes objects. Axes object 1 with title Linear Scale contains an object of type surface. Axes object 2 with title Log Scale contains an object of type surface.

    将底部绘图的 z 轴刻度更改为对数刻度。

    zscale(ax2,"log")

    Figure contains 2 axes objects. Axes object 1 with title Linear Scale contains an object of type surface. Axes object 2 with title Log Scale contains an object of type surface.

    输入参数

    全部折叠

    刻度值,指定为 "linear""log"。当您更改刻度时,MATLAB® 会将坐标区对象的 ZScale 属性更改为您指定的值。

    注意

    当您指定对数刻度时,坐标区在某些情况下可能会排除坐标:

    • 如果坐标包括正值和负值,则仅显示正值。

    • 如果坐标均为负值,所有值都带适当的符号显示在对数刻度上。

    • 不显示零值。

    目标 Axes 对象。如果不指定目标坐标区,zscale 使用当前坐标区。

    版本历史记录

    在 R2023b 中推出

    另请参阅

    函数

    属性