placing text on the figure while using scatter function

2 次查看(过去 30 天)
figure(1); hold on
scatter(1, 1, 100, 'k', 'o')
scatter(1, 2, 100, 'k', '+')
h = legend('SV1-SV7', 'Plus', 'Location', 'NorthEast');
set(h, 'FontSize', 14)
axis([0 3 0 3])
How can I add a text into this figure right below the legend box? I tried to place with location specified by the point (x,y) but axis data is not constant all the time so each time location of the text is changing w.r.t. axis data. Is there any way to place text right below the legend all the time (i.e. fixed location on the figure)?

采纳的回答

Walter Roberson
Walter Roberson 2016-2-18
You can set the Units for text() to be 'normal', and set the Position to have a X coordinate of 1, and set the Horizontal centering to have the text go to the left of that point. This will stick to the right margin if the xlim changes (such as if more data is added.)
  2 个评论
sermet
sermet 2016-2-19
Walter could you give me a code example what you meant? I couldn't get it exactly.
Walter Roberson
Walter Roberson 2016-2-19
th = text(1,.2,'hello','units','normal','horizontalalignment', 'right');
shows up 1/5 of the way up from the bottom of the plot, at the right hand side, completely inside the drawing axes but the right side of the text essentially touching the axes. It will stay in that relative position even if you explicitly or implicitly change the xlimits or ylimits.

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by