简体   繁体   English

在Matlab茎图中更改轴范围

[英]Change axis range in Matlab stem plot

The x-axis range seems to begin at the first data point and end at the last by default. 默认情况下,x轴范围似乎从第一个数据点开始,到最后一个数据点结束。 I'd like to extend this a little bit in both directions so my graph looks zoomed out a bit. 我想在两个方向上都进行一点扩展,以便我的图形看起来缩小一点。 How do I set this? 我该如何设置? I don't see it in the stem documentation. 我在主干文档中看不到它。

example code: 示例代码:

f = [0.0 0.45 0.55 1.0];
a = [1.0 1.0 0.0 0.0];

filter = firpm(10,f,a);

plot(f,a);
stem(filter);

and I want to change the x-axis from 0 to 20 (it currently defaults at 1 to 11). 我想将x轴从0更改为20(当前默认为1到11)。

This is not done by stem or any other plotting function. 这不是通过stem或任何其他绘图功能来完成的。 To control axis range you use either axis : 要控制轴范围,请使用任一axis

axis(limits) specifies the limits for the current axes. axis(limits)指定当前轴的极限。 Specify the limits as vector of four, six, or eight elements. 将限制指定为四个,六个或八个元素的向量。 [...] [...]

or xlim : xlim

xlim(limits) specifies the x-axis limits for the current axes. xlim(limits)指定当前轴的x轴限制。 Specify limits as a two-element vector of the form [xmin xmax] , where xmax is greater than xmin . 将限制指定为[xmin xmax]形式的两元素向量,其中xmax大于xmin [...] [...]
xl = xlim returns a two-element vector containing the current limits. xl = xlim返回包含当前限制的两元素向量。 [...] [...]

For example, to extend the current range of the x axis 1 unit to each side: 例如,要将x轴1单位的当前范围扩展到每一侧:

xlim(xlim + [-1 1])

(note that this uses the two types of calls described in the xlim documentation excerpts above). (请注意,这使用了上面xlim文档摘录中描述的两种类型的调用)。

Or, in your specific example, 或者,在您的特定示例中,

xlim([0 20])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM