how to change figure properties?

6 Ansichten (letzte 30 Tage)
Guillaume
Guillaume am 18 Aug. 2014
Kommentiert: Guillaume am 18 Aug. 2014
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

Akzeptierte Antwort

Adam
Adam am 18 Aug. 2014
Bearbeitet: Adam am 18 Aug. 2014
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 Kommentare
Adam
Adam am 18 Aug. 2014
Bearbeitet: Adam am 18 Aug. 2014
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 am 18 Aug. 2014
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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by