分享兴趣,传播快乐,增长见闻,留下美好!亲爱的您,这里是LearningYard学苑。
今天小编为大家带来MATLAB绘图-四种语法,欢迎您的用心访问!本期推文时长大约3分钟,请您耐心阅读。
Share interest, spread happiness, increase knowledge, and leave beautiful. Dear, this is the Learing Yard Academy!
Today, the editor brings the MATLAB Plotting - four syntaxes. Welcome to visit! This tweet usually takes about 3 minutes to read. Please read patiently.
01 legend
legend语法可以为每一个绘制的图形或线条添加说明性标签的图例。
The legend syntax can add a legend with descriptive labels to each plotted figure or line.
示例1:
Example1:
x = linspace(0,4*pi);
y1 = cos(x);
plot(x,y1)
hold on
y2 = sin(2*x);
plot(x,y2)
legend('cos(x)','sin(2x)')
示例2:
Example2:
x = linspace(0,4*pi);
y1 = sin(x);
plot(x,y1)
hold on
y2 = cos(2*x);
plot(x,y2)
hold off
lgd = legend('sin(x)','cos(2x)');
title(lgd,'小李Talk')
右上角即为添加的图例,图例的存在可以让我们了解到每条图形的信息。
The upper right corner is the added legend. The existence of the legend can let us know the information of each graph.
02 gtext
gtext(str) 可以在我们鼠标选择的位置插入我们要添加的文本,当鼠标停留在图窗界面时,鼠标指针会变成十字,此时,点击图窗或敲击除了enter以外任意键即可添加文本。它比图例位置更加灵活。
gtext(str) can insert the text we want to add at the position selected by the mouse. When the mouse stays on the figure interface, the mouse pointer will turn into a cross. At this time, click the figure or hit any key except enter. Add text. It is more flexible than legend position.
示例3:
Example3:
x=0:0.01:2*pi;
y=sin(x);
plot(x,y)
gtext('小李Talk sin(x)')
示例4:
Example4:
rdm=rand(4);
plot(rdm)
gtext('随机数据')
?
03 xlabel
xlabel(txt) 对当前坐标的 x 轴加标签,重新发出 xlabel 命令会将旧标签替换为新标签。
xlabel(txt) labels the x-axis at the current coordinates, reissuing the xlabel command will replace the old labels with the new labels.
示例5:
Example5:
plot((1:18).^2)
xlabel('experience')
?
示例6:
Example:
x = linspace(-4*pi,4*pi);
y = sin(x);
plot(x,y)
xlabel('-4\pi \leq x \leq 4\pi')
04 ylabel
ylabel(txt) 对当前坐标的 y 轴加标签,重新发出 ylabel 命令会将旧标签替换为新标签。
ylabel(txt) labels the y-axis of the current coordinate, reissuing the ylabel command will replace the old label with the new label.
示例7:
Example7:
plot((1:10).^2)
ylabel('Number','FontSize',12,'FontWeight','bold','Color','b')
END
今天的分享就到这里了,如果您对文章有独特的想法,欢迎给我们留言。让我们相约明天,祝您今天过得开心快乐!
That's all for today's sharing. If you have a unique idea about the article, please leave us a message, and let us meet tomorrow. I wish you a happy day!
参考资料:谷歌翻译、百度
本文由LearningYard学苑整理并发出,如有侵权请在后台留言沟通!