placing text on the figure while using scatter function

1 visualización (últimos 30 días)
sermet
sermet el 18 de Feb. de 2016
Comentada: Walter Roberson el 19 de Feb. de 2016
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)?

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Feb. de 2016
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 comentarios
sermet
sermet el 19 de Feb. de 2016
Walter could you give me a code example what you meant? I couldn't get it exactly.
Walter Roberson
Walter Roberson el 19 de Feb. de 2016
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.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by