Documentation

ylim

Set or queryy- 轴限制

Syntax

ylim(限制)
yl = ylim
ylim auto
ylim manual
m = ylim('mode')
___= ylim(target,___)

Description

example

ylim(limits)设置y- 轴限制for the current axes or chart. Specifylimitsas a two-element vector of the form[ymin ymax], whereymax大于ymin

example

yl= ylimreturns the current limits as a two-element vector.

ylim auto设置自动模式,使轴确定y- 轴限制。The limits span the range of the plotted data. Use this option if you change the limits and then want to set them back to the default values. This command sets theYLimModeproperty for the axes to'auto'

example

ylim manual设置手动模式,在当前值处冻结限制。如果要在使用该选项中保留当前限制时,请使用此选项。坚持,稍等command. This command sets theYLimModeproperty for the axes to'manual'

m= ylim('模式')returns the currenty- 轴限制mode, which is either'auto'或者'manual'。默认情况下,除非指定限制或将模式设置为手动,否则该模式是自动的。

example

___= ylim(target,___)uses the axes or chart specified bytarget而不是当前轴。指定targetas the first input argument for any of the previous syntaxes. You can include an output argument if the original syntax supports an output argument. Use single quotes around the mode inputs, for example,ylim(target,'auto')

Examples

collapse all

绘制一条线并设置y- 轴限制to range from -2 to 2.

x = linspace (0, 10); y = sin(x); plot(x,y) ylim([-2 2])

Create a surface plot and show onlyy大于0的值y-axis limit as 0 and let MATLAB choose the maximum limit.

[X,Y,Z] = peaks; surf(X,Y,Z) ylim([0 inf])

创建一个沿Y轴日期的水平条形图。将Y轴限制设置为从2014年6月1日到2014年6月10日。

t = datetime(2014,06,1) + caldays(0:20); y = rand(21,1); barh(t,y) tstart = datetime(2014,06,1); tend = datetime(2014,06,10); ylim([tstart tend])

Create a figure with two subplots and assign theAxes对象变量ax1ax2。Plot the same data in each subplot. Set they- 轴限制for the bottom subplot by specifyingax2作为第一个输入ylim

x = linspace (0, 10,1000); y = sin(10*x).*exp(.5*x); ax1 = subplot(2,1,1); plot(x,y) ax2 = subplot(2,1,2); plot(x,y) ylim(ax2,[-10 10])

使用手动模式维护电流y- 轴限制在轴上添加更多图时。

首先,绘制一条线。

x = linspace (0, 10); y = sin(x); plot(x,y)

Set they- 轴限制mode to manual so that the limits to not change. Use坚持,稍等在轴上添加第二个图。

ylimmanualholdy2 = 2*sin(x); plot(x,y2) hold离开

They- 轴限制do not update to incorporate the new plot.

Switch back to automatically updated limits by resetting the mode to automatic.

ylim汽车

Create a scatter plot of random data. Return the values of they- 轴限制。

x = randn(50,1); y = randn(50,1); scatter(x,y)

yl = ylim
yl =-2 3

Input Arguments

collapse all

Minimum and maximum limits, specified as a two-element vector of the form[ymin ymax], whereymax大于ymin。您可以将限制指定为数字,分类,日期或持续时间值。但是,您指定的值类型必须匹配沿y-axis.

您可以指定这两个限制,也可以指定一个限制,然后让MATLAB®汽车matically calculate the other. For an automatically calculated minimum or maximum limit, use-inf或者inf, respectively.

例子:ylim([0 1])

例子:ylim([-inf 1])

例子:Ylim([0 Inf])

Data Types:single|double|int8|INT16|INT32|int64|uint8|uint16|uint32|uint64|分类|约会时间|duration

Target axes or chart, specified as anAxesobject or a graphics object with anYLimits财产,例如热图目的。如果您不指定轴或图表,则ylim设置当前轴或图表的限制(由gca).

Output Arguments

collapse all

当前限制,作为表格的两元素向量返回[ymin ymax]

查询极限返回YLim或者YLimitsproperty value for the correspondingAxes或图形对象。

Current limits mode, returned as one of these values:

  • 'auto'— Automatically determine the limits.

  • 'manual'— Use manually specified limits that do not update to reflect changes in the data.

查询y- 轴限制mode returnsYLimModeproperty value for the correspondingAxes目的。

算法

Theylim功能集和查询与y- 轴限制。

  • YLim— Property that stores they- 轴限制。

  • YLimMode— Property that stores they- 轴限制模式。当您设置y- 轴限制, this property changes to'manual'

在R2006a之前引入

这个话题有帮助吗?