在 Matlab 茎图中更改轴范围
Change axis range in Matlab stem plot
默认情况下,x 轴范围似乎从第一个数据点开始到最后一个数据点结束。我想在两个方向上稍微扩展一下,这样我的图表看起来会缩小一点。我该如何设置?我没有在 stem 文档中看到它。
示例代码:
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);
并且我想将 x 轴从 0 更改为 20(目前默认为 1 到 11)。
这不是由 stem
或任何其他绘图函数完成的。要控制轴范围,您可以使用 axis
:
axis(limits)
specifies the limits for the current axes. Specify the limits as vector of four, six, or eight elements. [...]
或xlim
:
xlim(limits)
specifies the x-axis limits for the current axes. Specify limits as a two-element vector of the form [xmin xmax]
, where xmax
is greater than xmin
. [...]
xl = xlim
returns a two-element vector containing the current limits. [...]
例如,要将x轴的当前范围向每一侧扩展1个单位:
xlim(xlim + [-1 1])
(请注意,这使用了上述 xlim
文档摘录中描述的两种类型的调用)。
或者,在您的具体示例中,
xlim([0 20])
默认情况下,x 轴范围似乎从第一个数据点开始到最后一个数据点结束。我想在两个方向上稍微扩展一下,这样我的图表看起来会缩小一点。我该如何设置?我没有在 stem 文档中看到它。
示例代码:
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);
并且我想将 x 轴从 0 更改为 20(目前默认为 1 到 11)。
这不是由 stem
或任何其他绘图函数完成的。要控制轴范围,您可以使用 axis
:
axis(limits)
specifies the limits for the current axes. Specify the limits as vector of four, six, or eight elements. [...]
或xlim
:
xlim(limits)
specifies the x-axis limits for the current axes. Specify limits as a two-element vector of the form[xmin xmax]
, wherexmax
is greater thanxmin
. [...]
xl = xlim
returns a two-element vector containing the current limits. [...]
例如,要将x轴的当前范围向每一侧扩展1个单位:
xlim(xlim + [-1 1])
(请注意,这使用了上述 xlim
文档摘录中描述的两种类型的调用)。
或者,在您的具体示例中,
xlim([0 20])