【发布时间】:2014-10-08 08:46:05
【问题描述】:
请创建两个函数来重现我的意思:
第一个函数:
function testPlot1()
pointData = rand(20000,3);
figure;
%hold on; % <- if commented out, does not work
plot3(pointData(:,1), pointData(:,2), pointData(:,3),'Marker', '.', 'MarkerEdgeColor', 'b','MarkerSize', 5, 'LineStyle', 'none');
axis equal;
xh = xlabel('X');
yh = ylabel('Y');
zh = zlabel('Z');
set([xh,yh, zh],...
'fontweight','bold',...
'fontsize',14,...
'color',[0,0,0]);
view(0,20);
end
第二个功能:
function testPlot2(fighandle)
axes(fighandle);
hold on;
plot3([0 3],[0 3],[0 3], 'r', 'LineWidth', 10);
end
如果你现在打电话
testPlot1();testPlot2(gca)
您将获得以下信息:
如果您取消注释 testPlot1() 中的“hold on”行并再次调用上述语句,您将得到:
对我来说,这是不清楚的行为。在第一种情况下,testPlot1() 创建一个图形,将点云绘制到其中并修改轴属性。然后调用 testPlot2(gca) 将线添加到图中,但线被剪裁了。 然而,在第二种情况下,线条不再被剪裁。为什么现在不剪了,以前剪了?
这似乎与我在 testPlot1() 中的轴属性中所做的更改有关。有人可以向我解释这种行为吗? (为什么它可以与 hold on 一起使用,我对轴属性的更改会导致什么)
【问题讨论】:
-
这是一个错字吗:“(为什么它在等待时有效,...”它不适用于
hold on,这不是你的意思吗在问吗? -
不,不是错字。无论如何我都会进行编辑,因为这样有点混乱。我第一次调用 testPlot1();testPlot2(gca) 是在“hold on”被注释掉的时候。我也会试着澄清一下我的困惑
标签: matlab matlab-figure