Plot figure - get title

5 次查看(过去 30 天)
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?

采纳的回答

Star Strider
Star Strider 2019-1-26
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 个)

类别

Help CenterFile Exchange 中查找有关 Title 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by