필터 지우기
필터 지우기

How to Define Title Before Plotting?

조회 수: 5 (최근 30일)
Rightia Rollmann
Rightia Rollmann 2018년 9월 26일
답변: Rik 2018년 9월 26일
The code below works well:
hax = axes;
x = linspace(0,3);
y1 = sin(5*x);
plot(hax,x,y1)
hax.Title.String = 'TITLE'; %titling after plotting
But, is there any way to define the title before plotting? (and if it's not possible why?) The code below does NOT draw the title:
hax = axes;
x = linspace(0,3);
hax.Title.String = 'TITLE'; % titling before plotting (doesn't work)
y1 = sin(5*x);
plot(hax,x,y1)

채택된 답변

Rik
Rik 2018년 9월 26일
Because plot is a high level command and will clear a lot of things, unlike the line function (which is what plot is calling anyway). Using hold will work:
hax = axes;
x = linspace(0,3);
hax.Title.String = 'TITLE'; % titling before plotting (doesn't work)
hold(hax,'on')
y1 = sin(5*x);
plot(hax,x,y1)

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by