主要内容

pbaspect

Control relative lengths of each axis

描述

example

pbaspect(ratio)集情节rati盒子方面o for the current axes. The plot box aspect ratio is the relative length of thex-axis,y-axis, andz-轴。Specifyratioas a three-element vector of positive values that represent the ratio of thex-axis,y-axis, andz- 轴长。For example,[3 1 1]specifies that the length of thex- 轴等于长度的三倍y- 轴和z-轴。对于各个方向相等的轴长,请使用[1 1 1]

example

pb= pbaspect返回当前轴的绘图框纵横比。

example

pbaspect autosets an automatic mode, enabling the axes to choose the appropriate plot box aspect ratio. The mode must be automatic to enable the “stretch-to-fill”轴的特征。

pbaspect manualsets a manual mode and uses the ratio stored in thePlotBoxAspectratio属性目的。When the mode is manual, it disables the stretch-to-fill feature of the axes. Specifying a value for the plot box aspect ratio sets the mode to manual.

example

m= pbaspect('模式')returns the current mode, which is either'auto'或者'manual'。默认情况下,除非指定绘图框宽高比或将模式设置为手册,否则该模式是自动的。

example

___= pbaspect(ax,___)uses the axes specified byax而不是当前轴。将轴指定为任何先前语法的第一个输入参数。在周围使用单人行情'auto''manual'输入。

例子

全部收缩

Create a simple line plot. Make thex-axis,y-axis, andz-axis (not shown) equal lengths.

x = linspace(0,10);y = sin(x);图(x,y)pbaspect([1 1 1])

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

绘制表面并制作x-axis twice as long as they- 轴和z-轴。

[x,y] = meshgrid(-2:.2:2);z = x。*exp(-x。^2 -y。^2);冲浪(x,y,z)pbaspect([2 1 1])

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

当您指定绘图框宽高比时,关联的模式会更改为手册。查询当前的绘图框纵横比模式。

m = pbaspect('模式')
M ='手动'

创建一个随机数据的3-D散点图,并设置绘图框纵横比。然后还原回默认的绘图框纵横比。

X = rand(100,1); Y = rand(100,1); Z = rand(100,1); scatter3(X,Y,Z) pbaspect([3 2 1])

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

pbaspect汽车

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

Create a surface plot.

[x,y] = meshgrid(-2:.2:2);z = x。*exp(-x。^2 -y。^2);冲浪(X,Y,Z)

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

查询绘图框的纵横比。值表示比率x-axis length toy-axis length toz-axis length.

pb =pbaspect
pb =1×31.0000 0.9411 0.8496

从R2019B开始,您可以使用tiledlayoutnexttilefunctions. Call thetiledlayoutfunction to create a 2-by-1 tiled chart layout. Call thenexttile创建轴对象的功能ax1ax2。绘制每个轴。然后通过指定来设置较低图的绘图框宽高比ax2作为第一个输入参数pbaspectfunction.

tiledlayout(2,1) ax1 = nexttile; mesh(peaks(20)) ax2 = nexttile; mesh(peaks(20)) pbaspect(ax2,[2 2 1])

图包含2个轴对象。轴对象1包含类型表面的对象。轴对象2包含类型表面的对象。

Input Arguments

全部收缩

情节框纵横比, specified as a three-element vector of positive values. For example,pbaspect([3 2 1])specifies that the ratio of thex-axis length toy-axis length toz-axis length is 3 to 2 to 1. Thus, thex-axis is the longest and thez-axis is the shortest.

Specifying the ratio sets thePlotBoxAspectratio属性object to the specified value. ThePlotBoxAspectratioproperty interacts with thedataAspectAspectratio,xlim,Ylim, 和Zlim控制的属性以控制该长度和规模x-axis,y-axis, andz-轴。

Specifying the ratio sets theplotboxAspectratiomodeproperty to'manual'和disables thestretch-to-fill轴的行为。

Data Types:single|双倍的|int8|INT16|INT32|INT64|uint8|UINT16|uint32|uint64

目标轴, specified as an目的。如果您不指定轴,则pbaspectuses the current axes (gca)。

Output Arguments

全部收缩

Current plot box aspect ratio, returned as a three-element vector of values representing the ratio of thex-axis,y-axis, andz- 轴长。

查询绘图框的宽高比返回PlotBoxAspectratioproperty value for the目的。

Current plot box aspect ratio mode, returned as either'auto'或者'manual'。When the mode is automatic, MATLAB®确定适当的绘图框纵横比值。如果指定值,则模式更改为手册。

Querying the plot box aspect ratio mode returns theplotboxAspectratiomodeproperty value for the目的。

More About

全部收缩

Stretch-to-Fill

When the “stretch-to-fill” behavior is enabled, MATLAB stretches the axes to fill the available space. The axes might not exactly match the data aspect ratio, plot box aspect ratio, and camera-view angle values stored in itsDataAspectratio,PlotBoxAspectratio, 和CameraviewAngle特性。

If you specify the data aspect ratio, plot box aspect ratio, or camera-view angle, then the “stretch-to-fill” behavior is disabled. When stretch-to-fill is disabled, MATLAB makes the axes as large as possible within the available space and strictly adheres to the property values so that there is no distortion. For more information, see控制轴布局

算法

Thepbaspectfunction sets and queries several axes properties related to the data aspect ratio.

Version History

在R2006a之前引入