how to change figure properties?

조회 수: 6 (최근 30일)
Guillaume
Guillaume 2014년 8월 18일
댓글: Guillaume 2014년 8월 18일
Hello,
I opened two figures and I gave them names. I would like to change their properties not directly after I created them but a posteriori.
Here is an example of what I try to do:
fig1 = figure;
plot(1:10,1:10,'r+');
fig2 = figure;
plot(1:10,-1:-1:-10,'b+');
set(fig1,'xlabel','position')
But I get the error "The name 'xlabel' is not an accessible property for an instance of class 'figure'."
What should I do to have it working?
Thanks
Guillaume

채택된 답변

Adam
Adam 2014년 8월 18일
편집: Adam 2014년 8월 18일
xlabel is a property of the axes, not the figure
(I assume that is enough for you to solve the problem, if not I can expand it!)
  댓글 수: 3
Adam
Adam 2014년 8월 18일
편집: Adam 2014년 8월 18일
There are a few ways you can do it, but maybe simplest is just something like:
fig1 = figure; axes1 = gca;
plot(1:10,1:10,'r+');
fig2 = figure; axes2 = gca;
plot(1:10,-1:-1:-10,'b+');
set(axes1,'xlabel','position')
I think that should work, though I don't have time right now to test it.
The other way that comes to mind is finding the axes as a child of the figure. but that is more complicated and not necessary when you can just store the axes handle.
Guillaume
Guillaume 2014년 8월 18일
What you wrote does not directly work but I found how to solve the problem:
set(get(axes1,'XLabel'),'String','position')
Thanks for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by