4 I- j7 V, S4 ^+ O2 q, ] A + @$ i/ i( _$ O- d' F. D5 ]) s
yl = ylim 将当前限制返回为两个元素向量。 % C' c* p; j4 @0 M 4 D, r5 x4 }9 O例子: ! q t! R& k* o 6 C/ _, J3 B) \1 ]) e- _! D* s创建随机数据的散点图。返回 y 轴限制的值。" a. S4 S1 M; i. w3 T
, M9 r D8 L7 ]9 r& [ ) D! f7 n* N, c' f, n8 V 6 V1 t" G# ]8 FSet the y-axis limits mode to manual so that the limits to not change. Use hold on to add a second plot to the axes. $ g+ \! s( {+ i3 R/ d3 H, b' X& i* _ 3 e; n; z) T0 q2 z
6 m( o, g2 z" QThe y-axis limits do not update to incorporate the new plot. 1 @( K. d" v8 P6 I' e0 W6 |( {7 a8 \# C g% v: m: z
Switch back to automatically updated limits by resetting the mode to automatic.( [* V8 o3 P+ u A6 F5 q0 z; S
! Y: {9 i* h+ E2 ~9 r+ Z- g7 Y t) d4 H9 P5 ?: `/ r
: K8 E7 P# a: ?: l# \
m = ylim ("mode") 返回当前的 y 轴限制模式, 即 "auto" 或 "manual"。默认情况下, 除非您指定限制或将模式设置为manual, 否则模式是auto。2 Y& p# { f j. d' u# b
D( A/ T5 ^ Z5 c8 `2 w9 f
___ = ylim(target,___) 使用由目标指定的轴或图表, 而不是当前坐标轴。将目标指定为以前任何语法的第一个输入参数。如果原始语法支持输出参数, 则可以包括输出参数。在模式输入周围使用单引号, 例如, ylim (target , "auto")。/ x( J |& i) y1 k8 P2 x4 E' s
& a( x3 C6 G' K2 `7 Q0 Y# {- Y例子:) x; [" l) [3 d' Y" @. H
' L) |1 w X8 k
Create a figure with two subplots and assign the Axes objects to the variables ax1 and ax2. Plot the same data in each subplot. Set the y-axis limits for the bottom subplot by specifying ax2 as the first input to ylim. ( H* A2 W- o% e" F" H- f " _8 ]4 r) t& B4 l+ X创建一副拥有两个子图的图像,并把 Axes对象赋值给两个变量 ax1和ax2。在两幅子图中画同样的数据。通过将 ax2 指定为 ylim 的第一个输入, 为底部子图设置 y 轴限制。. L. u( O: a( a" p
1 k* [6 z9 a9 g! t
; U4 m( z( i& z; P. a% n$ Y
: l$ P9 a4 N: K4 o1 G9 B
再送几个案例:. Y8 z. `6 b( G' f! A7 [( z
2 s' d& {% z( O! ~ Use Semiautomatic y-Axis Limits9 i) t Q' {! K5 P2 V( f' K
* m0 U* E2 S) v( E/ \) Z2 qCreate a surface plot and show only y values greater than 0. Specify the minimum y-axis limit as 0 and let MATLAB choose the maximum limit.- |5 |$ X3 P( D9 |3 ^, w
; f) `) N5 y, x( B, ~只关注y轴就可以看出区别了。2 r( b; S5 k) |5 e
6 A6 b L2 {: j/ U' l# oSet Limits for y-Axis with Dates0 ?+ Z9 I0 M' \. h
! O) M1 ~3 C, b- v1 b$ u! ^: mCreate a horizontal bar chart with dates along the y-axis. Set the y-axis limits to range from June 1, 2014 to June 10, 2014." p u! U' K9 g% B- M; S
5 C8 o$ T% _, O% Q( o. F8 ^
意思是创建一个水平条形图,日期位于y轴,设置y轴的限制为从 June 1, 2014 to June 10, 2014.5 F t5 B, i4 H$ S/ w
5 k- m" G9 O" H, }8 R/ j( b& Z, G
1 C$ @0 g. i( G) b* s( r0 y' x1 g0 A0 |
) p. V5 R( P# R3 F( [2 f( b6 N
7 h3 H3 g) g! h% i. Y+ M* @xlim的用法和ylim几乎一模一样,这里仅仅给出英文版介绍,就不详述了。zlim也一样,就不说了。% z4 }7 U! M+ a, d4 q* M% D
5 p- |7 f1 n- L# b( W xlim * @, \# E& s, d$ Q* m; U7 p- u' d3 ` `5 R
Set or query x-axis limits2 U$ @2 z2 Y" e0 t. L) j8 ` _) V
$ ^* z% e6 U' P* ?5 N' [4 b; vcollapse all in page1 Z2 [) }! ?* p
( Y- P+ q) Z' _$ N Syntax4 W8 S/ c d/ {: B) }2 G! n
6 I- p4 I {- D' cxlim(limits) ' O* B7 i! m( v& K6 y+ i3 ~' W2 M7 v. k! |; ?, N+ C5 X
xl = xlim 5 o* A' l3 O' O& t; i, `! T; j) A" n; D/ H
xlim auto 2 E3 h o1 f+ N4 F o) ] }6 l6 ]. I3 V$ w2 t+ |* ^/ d
xlim manual# V1 Z5 B m- }3 g* G
- `* h- t- f' P; y$ {1 Pm = xlim('mode') 5 k% ]) R2 g. K( \2 w7 g; X1 X+ R [% W* t/ e) D; \" _
___ = xlim(target,___)! c# x0 g* e4 B) _7 ~
- |1 ~( b2 e. r: t+ [ R7 F Description + h7 t9 N+ j7 o, g5 I , J6 {' V! | V3 Y4 `2 S. i$ Aexample I/ B+ R' {! l8 c+ {2 n4 @ ( N5 r. I9 H5 C8 _! e9 ]xlim(limits) sets the x-axis limits for the current axes or chart. Specify limits as a two-element vector of the form [xmin xmax], where xmax is greater than xmin. 4 f ]/ j+ j W9 i$ P9 \" u, j* Q, ^7 m. G+ D7 E: z& ?% M
example 6 P' i; G6 P+ B. a* I ; ?, W, D! U7 C. k1 k" T; F' t6 txl = xlim returns the current limits as a two-element vector.+ N1 L: x; q4 B4 }# _
* I2 r) t* n, R# c% r# p, \xlim auto sets an automatic mode, enabling the axes to determine the x-axis limits. 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 the XLimMode property for the axes to 'auto'." m9 J) c5 `0 n Y! s3 W
! ]5 n4 p& e' t D1 {0 a
example " N- V8 @2 T" Z- N( m/ R. n# L 4 l* D0 U4 S% E# C% |xlim manual sets a manual mode, freezing the limits at the current values. Use this option if you want to retain the current limits when adding new data to the axes using thehold on command. This command sets the XLimMode property for the axes to 'manual'.0 Q; B0 W k8 P' x5 [
7 ]+ g5 |8 `7 A% tm = xlim('mode') returns the current x-axis limits mode, which is either 'auto' or 'manual'. By default, the mode is automatic unless you specify limits or set the mode to manual." U4 G! @5 Q, z) P3 l) B" ~
% a( w6 E/ Z1 z- B. x4 Z4 j- ^) Y
example: K W/ X/ v" f. E9 `2 x
+ y4 }2 r. Y/ \- B% k6 _ f
___ = xlim(target,___) uses the axes or chart specified by target instead of the current axes. Specify target as 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, xlim(target,'auto'). 4 H2 }" ^. F* s( }+ B ( `9 a1 ?, R3 Z / U- C5 E/ _! j* ]1 Z