필터 지우기
필터 지우기

How to change the axis properties of a graph?

조회 수: 17 (최근 30일)
Emerson De Souza
Emerson De Souza 2011년 10월 18일
Hi, I want to change the FontSize, FontName and FontWeight of the axis from my graph
but I only get error messages. Below you find the commands that I run and the error:
SCRIPT:
clear all;
close all;
%prepare data
x = 0:pi/100:2*pi;
y = sin(x);
h=plot(x,y);
%curve properties
set(h,'LineWidth',3,{'LineStyle'},{'.'})
set(h,{'Color'},{'r'})
%label properties
title('TEST','FontSize',26, 'FontName','Arial', 'FontWeight','bold')
xlabel('Time (seconds)','FontSize',20, 'FontName','Arial','FontWeight','bold')
ylabel('Amplitude (\mum)','FontSize',20, 'FontName','Arial','FontWeight','bold')
%axis properties
axis([0 7 -1.2 1.2],'FontSize',26, 'FontName','Arial', 'FontWeight','bold');
legend(h,'sin(x)',3, 'BackgroundColor','b')
legend('boxoff')
ERROR:
??? Error using ==> axis at 183
Unknown command option FontSize
Error in ==> TEST at 18
axis([0 7 -1.2 1.2],'FontSize',26, 'FontName','Arial','FontWeight','bold');
I also wanted to change the color of the legend box from white or transparent to any
arbitray color. I read the documentation and used the legend function but it did not work.
I hope someone know what is going wrong in these command lines
Thanks
Emerson

채택된 답변

Honglei Chen
Honglei Chen 2011년 10월 18일
Hi,
You can do
set(gca)
to see all properties of an axis. To modify either one of them, you can do
set(gca,'Name',Value)

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 10월 18일
The first argument to axes() may be a scalar value which must be an axes handle.
After that (if it is there at all), you may have name/value pairs.
Your first argument is not a scalar, so the command is not recognized.
Perhaps you want to prefix the vector with the 'Position' keyword.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by