how to change figure properties?
4 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Adam
on 18 Aug 2014
Edited: Adam
on 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 Comments
Adam
on 18 Aug 2014
Edited: Adam
on 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.
More Answers (0)
See Also
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!