placing text outside the axis in the figure
96 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sermet
el 19 de Feb. de 2016
Respondida: Star Strider
el 19 de Feb. de 2016
figure(1); hold on
scatter(1, 1, 100, 'k', 'o')
scatter(1, 2, 100, 'k', '+')
h = legend('circle', 'Plus', 'Location', 'NorthEast');
set(h, 'FontSize', 14)
axis([0 3 0 3])
text=('information:')
I need to place text string outside the axis in the figure. If it is not possible I need to insert text right below the legend. Scatter data is not constant all the time so the location of the text wouldn't depend on the axis data.
Thanks in advance
1 comentario
Respuesta aceptada
Star Strider
el 19 de Feb. de 2016
I don’t know where you want to put them outside the axes, so this code puts them below the legend instead. It is adaptive, and uses the 'Position' property of the legend and the axis limits to place the text object. You will have to experiment with it to get the result you want:
figure(1); hold on
scatter(1, 1, 100, 'k', 'o')
scatter(1, 2, 100, 'k', '+')
h = legend('circle', 'Plus', 'Location', 'NorthEast');
set(h, 'FontSize', 14)
axis([0 3 0 3])
axlim = get(gca, 'XLim'); % Get ‘XLim’ Vector
aylim = get(gca, 'YLim'); % Get ‘YLim’ Vector
legpos = get(h, 'Position'); % Get ‘legend’ 'Position' Vector
x_txt = min(axlim) + diff(axlim)*legpos(1) + 0.05*diff(aylim); % Set ‘x’-Coordinate Of Text Object
y_txt = min(aylim) + diff(aylim)*legpos(2) - 0.01*diff(aylim); % Set ‘y’-Coordinate Of Text Object
text(x_txt, y_txt, 'information:')
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!