我试图以不同的方式将轴标记为这些数字,我试图仅将一个x轴标记为"时间(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)
要更改标签,您需要获取标签本身的句柄。 固定代码:
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)
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