Plot figure - get title
8 views (last 30 days)
Show older comments
Hello,
I am reading the following code, and I do not understand the last two lines. I run it, but it does not change the figure. So I am quite confused what are the purpose of the these code lines?
Is there anyone having an idea? If so, could you kindly tell me?
Thanks a lot!
figure;
plot(xx,yy,'LineWidth',2);
axis([-1 1 -0.2 1.2] )
h = legend(['f*';'10';'Ch']);
v = get(h,'title'); % what is the purpose?
set(v,'string','Order'); % what is the purpose?
0 Comments
Accepted Answer
Star Strider
on 26 Jan 2019
The purpose appears to be to set the 'title' property of the legend object to be 'Order'.
At least that what appears when I run this code:
xx = -1:0.1:1;
yy = xx.^2;
figure;
plot(xx,yy,'LineWidth',2);
axis([-1 1 -0.2 1.2] )
h = legend(['f*';'10';'Ch']);
v = get(h,'title'); % what is the purpose?
set(v,'string','Order'); % what is the purpose?
See the documentation section on Add Title to Legend (link) for details. Creating legend titles this way is relatively recent.
0 Comments
More Answers (0)
See Also
Categories
Find more on Title 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!