Matlab:来自`text()`的文本底部被切碎

时间:2018-05-09 14:58:03

标签: matlab-figure

我想在3D条形图中标记我的条形图:

clf
yMax = 2;
xMax = 3;
z=floor(10*rand(yMax,xMax));
bar3(z)
xlabel('x-axis')
ylabel('y-axis')
x = reshape( repmat(1:xMax,yMax,1), [], 1 );
y = repmat( (1:yMax)', xMax,1 );
%htext = text( x, y, z(:), repmat( {'TEST'}, xMax*yMax, 1 ) )
htext = text( x, y, z(:), 'TEST' )

无论我制作多大的数字,文字都会在底部被切断:

enter image description here

任何人都可以提出一种方法来追踪原因,并/或建议解决方案吗?

1 个答案:

答案 0 :(得分:0)

我很幸运能和大师一起玩几分钟。解释:VerticalAlignment默认为middle,适用于2D绘图。但是,对于上面的每个3D条形,middle表示文本的中间位于框的顶部表面。因此,文本的下半部分是框内。通过修改text命令来解决问题:

htext = text( x, y, z(:), 'TEST' , 'VerticalAlignment','Bottom' )

奇怪的是我在网络搜索中找不到它,但希望这个答案能解决这个问题。

相关问题