● 그래프 이름 지정

title('그래프 이름');

ex) title('Spiraea's lab');



● x축, y축 제목 지정 (labeling)

xlabel('x축 제목');

ylabel('y축 제목');

ex) xlabel('this is x-axis');

ylabel('this is y-axis');



● x축, y축 범위 지정

axis([xmin, xmax, ymin, ymax]); ==> axis([x축 최솟값, x축 최댓값, y축 최솟값, y축 최댓값]);

ex) axis([0,810,0.995,1.025])



● 글자 크기 조정

1) 범례(legend)의 글자 크기: set(legend이름, 'FontSize', 글자크기);

(이것을 사용하기 위해서는 legend 지정을 할 때, legend 이름을 설정해주어야 한다.)

 ex) legend_A = legend('A');

set(legend_A, 'FontSize', 15);


2) 전체 글자 크기 조절: set(gca,'FontSize',글자크기);

ex) set(gca,'FontSize',20);



● 축의 간격 조정

1) x축:

> set(gca,'XTick',[최솟값:간격:최댓값]);

> set(gca,'XTick',[원하는 값 나열]);

ex) set(gca,'XTick',[-5:0.5:7]);

set(gca,'XTick',[0 1 3 8]);

2) y축은 XTick 대신 YTick 사용



● 축의 눈금 변경

1) x축: set(gca,'XTickLabel',눈금 이름);

ex) set(gca, 'XTickLabel', {'h','e','l','l','o'});


2) y축은 XTick 대신 YTick 사용



● 축의 유효 숫자 변경

1) x축의 유효 숫자 변경

ex) set(gca, 'XTickLabel', num2str(get(gca, 'XTick')', '%.3f'));


2) y축의 유효 숫자 변경

ex) set(gca, 'YTickLabel', num2str(get(gca, 'YTick')', '%.3e'));




<참고>

>> num2str : number to string (숫자에서 문자열로 바꿔주는 함수)

num2str(get(gca, 'YTick')', '%.3e') : y축의 숫자를 소수점 3자리 까지의 지수형식의 문자열로 변환.


num2str Convert numbers to a string.


    T = num2str(X) converts the matrix X into a string representation T

    with about 4 digits and an exponent if required.  This is useful for

    labeling plots with the TITLE, XLABEL, YLABEL, and TEXT commands.

 

    T = num2str(X,N) converts the matrix X into a string representation

    with a maximum N digits of precision.  The default number of digits is

    based on the magnitude of the elements of X.

 

    T = num2str(X,FORMAT) uses the format string FORMAT (see SPRINTF for

    details).

 

    Example 1:

        num2str(randn(2,2),3) produces a string matrix such as

 

         1.44    -0.755

        0.325      1.37

 

    Example 2:

        num2str(rand(2,3) * 9999, '%10.5e\n') produces a string matrix

        such as

 

        8.14642e+03

        1.26974e+03

        6.32296e+03

        9.05701e+03

        9.13285e+03

        9.75307e+02








적용




>> plot(x,y);

>> title('random number');

>> xlabel('sequence');

>> ylabel('probability');

>> axis([0 11 -0.1 1.1]);

>> set(gca,'FontSize',12);

>> set(gca,'YTick',[0:0.1:1]);

>> set(gca,'XTickLabel',{'a','b','c','d','e','f'});

>> set(gca, 'YTickLabel', num2str(get(gca, 'YTick')', '%.3e'));




+ Recent posts