placing text on the figure while using scatter function

1 回表示 (過去 30 日間)
sermet
sermet 2016 年 2 月 18 日
コメント済み: Walter Roberson 2016 年 2 月 19 日
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 Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by