我试图以不同的方式将轴标记为这些数字,我试图仅将一个x轴标记为“Time(s)”,并将第一个y轴标记为“f(t)”第二个是“g(t)”。在实现某种字体和大小的同时,我的书并未明确说明如何执行此操作,并且互联网不是很有帮助。
我知道我必须实现这一点,但我不知道代码中的哪个位置会将其放入:
% swEPSfigure.m
%
% Set the default font names and sizes for the eps figures
% prepared for Scientific Word
% In SW, a 65-50% reduction of the figures is normally done
% Full LaTeX commands can be used in the labels, legends, etc.
%
%
set(0,'DefaultAxesFontName','Times New Roman');
set(0,'DefaultTextFontName','Times New Roman');
set(0,'DefaultAxesFontSize',18);
set(0,'DefaultTextFontSize',18);
set(0,'defaulttextinterpreter','latex'); % Use LaTeX to add Math symbols
disp(' ');
disp(' Changing Default Font to Times New Roman');
disp(' Changing Default Font Size to 18');
disp(' ');
这是我目前的代码:
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');
set(gca,'YLim',[-1 2],'YTick',-1:1:2,'XTick',0:.5:2)
subplot(2,1,2);
hPlot2 = plot(x,y2,'k*');
set(gca,'YTick',[-0.2,0,0.2,0.4,0.6],'XTick',0:.5:2)
答案 0 :(得分:0)
我确实回答了相同的帖子。 要更改标签,您需要获取标签本身的句柄。固定代码:
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');
set(gca,'YLim',[-1 2],'YTick',-1:1:2,'XTick',0:.5:2)
set(get(gca,'XLabel'),'String','X axis label 1') %get the handle to XLabel and set its value
set(get(gca,'YLabel'),'String','Y axis 1') %get the handle to YLabel and set its value
subplot(2,1,2);
hPlot2 = plot(x,y2,'k*');
set(gca,'YTick',[-0.2,0,0.2,0.4,0.6],'XTick',0:.5:3)
set(get(gca,'XLabel'),'String','X axis label 2') %get the handle to XLabel and set its value
set(get(gca,'YLabel'),'String','Y axis 2') %get the handle to YLabel and set its value