Matlab - 改变整个图形上文本字段的高度

时间:2013-10-29 10:15:17

标签: matlab

有没有办法在不改变x和y位置的情况下改变整个图形上文本字段的高度?

要改变我们必须使用位置,这需要改变坐标。我想只改变高度,而不改变x和y。

4 个答案:

答案 0 :(得分:2)

只需存储当前的x和y,并在set调用中使用它们,如下所示:

old_pos = get(text_field_handle,'Position');
set(text_field_handle,'Position',[old_pos(1:2),new_width,new_height]);

答案 1 :(得分:1)

嗯,您可以更改FontSize属性,这不会更改坐标,但会增加宽度和高度。有关详细信息,请参阅文档中的Text Properties

答案 2 :(得分:1)

我假设您正在使用uicontrol('style','text')

来自您的uicontrol properties

  

位置

position rectangle

*Size and location of uicontrol*. The rectangle defined by this property 
specifies the size and location of the control within the parent figure 
window, uipanel, or uibuttongroup. Specify Position as:

[left bottom width height]

where left and bottom define the distance from the lower-left corner of the 
container to the lower-left corner of the rectangle. width and height are the 
dimensions of the uicontrol rectangle.

然后,您只需更改widthheight,即可保留原始leftbottom

答案 3 :(得分:1)

可以设置Margin对象的text属性来增加对象的高度而不更改fontsize,但这会影响文本对象的高度和宽度。我不确定使高度小于Matlab认为的文本高度意味着什么,所以我假设你有兴趣增加尺寸。

如果您愿意使用LaTeX解释器,则增加文本对象的高度相对容易。你只需要添加一个任何高度的“空”框:

text(0.5, 0.25, 'Hello World\parbox{\textwidth}{\vspace{1in}}', 'Interpreter', 'LaTeX', 'BackgroundColor',[1, 0, 0]);

这不会使高度增加1英寸,而是更像是1英寸减去基线跳跃。确定显示单位的实际高度增加会增加更多问题。您可以使用unicode字符更改高度,因此跳过LaTeX解释器,但我不知道如何。