标记不同的图形,字体,大小MATLAB [英] Labeling different figures, font,size MATLAB
本文介绍了标记不同的图形,字体,大小MATLAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试基本上复制此图以用于最终的练习,但我不知道如何更改字体,大小或标记轴.简而言之,我需要完全从我的代码中复制此图.我需要将字体设置为18的新罗马字体,并将标记的大小设置为8.我如何将代码格式化为这种字体?
这是我的代码:
clear
clc
x = linspace(0,2);
y1 = sin(2*pi*x);
y2 = exp(-0.5*2*pi*x).*sin(2*pi*x);
figure
subplot(2,1,1);
hPlot1 = plot(x,y1,'rs');
ylabel('f(t)')
set(gca,'YLim',[-1 2],'YTick',-1:1:2,'XTick',0:.5:2)
subplot(2,1,2);
hPlot2 = plot(x,y2,'k*');
xlabel('Time(s)')
ylabel('g(t)')
set(gca,'YLim',[-0.2,0.6],'YTick',[-0.2,0,0.2,0.4,0.6],'XTick',0:.5:2)
推荐答案
将xlabel('Time(s)')
替换为:
xlabel('Time(s)','FontName','TimesNewRoman','FontSize',18)
,并对ylabel
执行相同操作.
对于标记大小,将hPlot1 = plot(x,y1,'rs');
替换为
For the marker size, replace hPlot1 = plot(x,y1,'rs');
by
hPlot1 = plot(x,y1,'r-',x(1:5:end),y1(1:5:end),'ks','MarkerSize',8);
与其他情节相同.
最后,您可以使用text
函数将文字添加到图形中,例如:
Finally, you can add text to the figure using the text
function, e.g.:
text(0.5,1.5,'Harmonic force f(t) = sin(\omega t)')
同样,您可以更改字体大小和字体名称,就像使用xlabel
和ylabel
一样.
Again, you can change the font size and font name, as with xlabel
and ylabel
.
这篇关于标记不同的图形,字体,大小MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文