【发布时间】:2014-09-22 18:08:12
【问题描述】:
我试图在 MATLAB 中在旋转图上创建一个文本框,但我不希望文本框更改其相对于图形的位置。我认为text 函数中的'units','normalized' 可以做到这一点,但它并不完全有效,如下面的示例所示。我想我可以使用uicontrol,但我想使用希腊字母,但我无法让uicontrol 看起来和text 一样好。以下示例重现了我的问题。您会注意到文本框随着情节的旋转而移动,但我希望它只停留在它开始的左上角区域。谢谢!
part_x = rand(1000,3)-.5; %generate random 3D coordinates to scatter
fig1 = figure;
scatter3(part_x(:,1), part_x(:,2), part_x(:,3))
axis equal vis3d
axis([-1 1 -1 1 -1 1])
set(fig1,'color','w')
for tau = 1:150
view(tau+20,30); %spin the plot
pause(.01)
if tau~=1; delete(tau_text); end; %delete the previous text if it exists
tau_text = text(.1,.7,...
['\tau = ',num2str(tau)],...
'units','normalized',... %text coordinates relative to figure?
'Margin',3,... %these last 3 lines make it look nice
'edgecolor','k',...
'backgroundcolor','w');
end
【问题讨论】:
-
+1 表示可重复的示例
标签: matlab text 3d location figure