Text location

379 次查看(过去 30 天)
Jorge
Jorge 2011-2-6
Is possible put a text in a determinated position, for example, at the top left?

采纳的回答

Walter Roberson
Walter Roberson 2011-2-6
text(0,1,'Your String','Units','normalized')
  3 个评论
Walter Roberson
Walter Roberson 2011-2-6
And the OP then talks about text() needing coordinates to locate the text within the figure, which is not something that text() ever did. We conclude that the OP was using the wrong terminology.
Walter Roberson
Walter Roberson 2018-10-5
h = annotation('textbox', [0 1 0 0], 'String', 'YourString', 'FitBoxToText', true);

请先登录,再进行评论。

更多回答(4 个)

Jan
Jan 2011-2-6
FigH = figure;
AxesH = axes('Parent', FigH, ...
'Units', 'normalized', ...
'Position', [0, 0, 1, 1], ...
'Visible', 'off', ...
'XLim', [0, 1], ...
'YLim', [0, 1], ...
'NextPlot', 'add');
TextH = text(0,1, 'Top left', ...
'HorizontalAlignment', 'left', ...
'VerticalAlignment', 'top');
Now you can inspect the properties with "get(TextH)" or "set(TextH)" for further adjustments.
Sometimes a UICONTROL('Style', 'text') is easier, because it does not need the invisible full-figure AXES object.

RonE
RonE 2018-10-4
I find the documentation on 'text' to be nearly useless in this matter. The following places text at the top left of the graph.
ylimits = ylim;
ymax = ylimits(2);
vert_spacing = ymax/47; %may have to experiment with this #
text(10, ymax-vert_spacing*1, 'Line 1');
text(10, ymax-vert_spacing*2, 'Line 2');
...

Jiro Doke
Jiro Doke 2011-2-6
What do you mean "top left"? Top left of the figure? Top left of the screen? Top left of the axes?
Have you looked at the function text?
  3 个评论
Jorge
Jorge 2011-2-6
The text needs a pair of coordinates to locate it in the figure. In the case of the legend there is an option to place it in different positions through the property "location". Is possible use the property "location" with text? Thanks
Jiro Doke
Jiro Doke 2011-2-6
"text" doesn't have that option.

请先登录,再进行评论。


Vieniava
Vieniava 2011-2-6
编辑:John Kelly 2015-2-26

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by