2014-02-11 6 views
3

그림에 대한 MATLAB에서 x 축의 글꼴 크기 속성을 변경하는 방법이 있습니까? x 축 (제목이 아닌 xlabel 속성으로 수정할 수 있음)에서 값의 크기를 변경해야합니다. 다음 코드를 가지고 있습니다.x 축의 글꼴 크기를 변경하는 방법은 무엇입니까?

%% Some figure properties: 
width=15;height=20;alw=0.75; 

%% Figure: 
for i=1:8 
     figure;set(gcf,'color','white'); 
     pos=get(gcf, 'Position'); 
     set(gcf, 'Position', [pos(1) pos(2) width*100, height*100]); 
     set(gca, 'LineWidth', alw);axis off; 
     axes('position',[0.06 0.08 0.87 0.38]) 
     plot(0:24,s(i).obs(:,1),'linewidth',2,'color','b');hold on; 
     plot(0:24,s(i).sim(:,1)-273.15,'linewidth',2,'color','r'); 
     legend('Obs','Sim','location','northeastoutside'); 
     set(gca,'xtick',0:24,'xticklabel',0:24); 
     set(gca,'ytick',2:2:28,'yticklabel',2:2:28); 
     xlabel('Hour');ylabel('[°C]');axis([0 24 2 28]);grid on; 
     axes('position',[0.06 0.53 0.87 0.38]); 
     plot(s(i).time.obs,s(i).serie.obs,'b');hold on; 
     plot(s(i).time.sim,s(i).serie.sim-273.15,'r'); 
     datetick('x','myy');axis tight;grid on; 
     legend('Obs','Sim','location','northeastoutside'); 
     title([s(i).name ', porcNaN: ' num2str(roundn(s(i).rnan,-1)) ... 
      '%, period: ' datestr(s(i).period(1,:),20) ' - '... 
      datestr(s(i).period(2,:),20)],'fontsize',12); 
     ylabel('[°C]');set(gca,'fontsize',8) 
     image_name=['temp_sup_' s(i).name]; 
     print(image_name,'-dpng','-r600') 
end 

"s"는 구조체입니다. 문제는 두 번째 플롯 (위의 그림)의 x 축에있는 값이며, datetick은 모든 월과 연도 값을 넣습니다.이 정보가 필요합니다 (매월 1 개월).하지만 아주 가깝습니다. "fontsize"속성을 알고 있지만이 속성은 두 축 (x 및 y)의 글꼴 크기를 변경하며 x 축만 변경하면됩니다.

+0

축의 눈금 레이블의 크기를 변경하려고합니까? 귀하의 코드는 이것보다 복잡합니다 .... – jvriesem

답변

9

나는 항상 다음과 같은 방법으로 그것을 할 :

이런 식으로
plot(X) 
set(gca, 'FontName', 'Arial') 
set(gca, 'FontSize', 12) 
ylabel('Label Y axis') 
xlabel('Label X axis') 

는, 축과 레이블이 요청 된 글꼴과 크기를해야합니다. 'set' 다음에 'xlabel''ylabel'을 입력하는 것이 중요합니다. 이 경우 주문이 중요합니다.

xlabel, ylable, 범례, 플롯의 글꼴을 다음과 같이 설정하는 다른 방법이 있습니다. 그것은 위의 답변을 보완 할 수 있습니다 :

% Define values 
linewidthnumber = 2; 
legendfontsize = 12; 
labelfontsize = 12; 
axisfontsize = 12; 
custom_plot_handle_name = plot(x); 
custom_legend_handle_name = legend(); 
custom_x_label_name = xlabel(); 
custom_y_label_name = ylabel(); 

% Set the parameters now to the given values 
set(h, 'Linewidth', linewidthnumber); 
set(custom_legen_handle_name,'FontSize', legendfontsize); 
set(custom_x_label_name, 'FontSize', labelfontsize); 
set(custom_y_label_name, 'FontSize', labelfontsize); 
set(gca, 'FontSize', axisfontsize); 
+0

AWESOME. 그냥 참고하시기 바랍니다 : 다른 사람들의 솔루션과 달리이 방법은 반올림 로그 로그 플롯에서 작동합니다. 나는 그것이 일반적으로 작동하는 것 같아요. – jvriesem

관련 문제