如何画具有多列的图例?

时间:2026-02-14 09:20:48

1、命令行键入:

x = linspace(0,10);

%定义x。

如何画具有多列的图例?

2、命令行键入:

y1 = sin(x);

y2 = sin(0.9*x);

y3 = sin(0.8*x);

y4 = sin(0.7*x);

y5 = sin(0.6*x);

y6 = sin(0.5*x);

%定义y1,y2,y3,y4,y5,y6。

如何画具有多列的图例?

3、命令行键入:

plot(x,y1,'DisplayName','sin(x)')

%画图。

如何画具有多列的图例?

4、命令行键入:

hold on

%图形保持。

5、命令行键入:

plot(x,y2,'DisplayName','sin(0.9x)')

plot(x,y3,'DisplayName','sin(0.8x)')

plot(x,y4,'DisplayName','sin(0.7x)')

plot(x,y5,'DisplayName','sin(0.6x)')

plot(x,y6,'DisplayName','sin(0.5x)')

%画图。

如何画具有多列的图例?

6、命令行键入:

hold off

%取消保持

7、命令行键入:

lgd = legend;

%标签。

如何画具有多列的图例?

8、命令行键入:

lgd.NumColumns = 2;

%通过将 NumColumns 属性设置为 2 来添加一个具有两列的图例。

如何画具有多列的图例?

© 2026 一点知道
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com