How to halt matlab plot3 scale

允我心安 提交于 2019-12-02 03:30:57

Try setting the XLim, YLim, and ZLim properties before plotting. For example,

xlim=[-1 1];

or

haxe = gca;
haxe.XLim = [-1 1];

Also, you could set XLimMode, YLimMode, and ZLimMode properties to manual. For example,

haxe.XLimMode = 'manual'

For more information regarding axis properties see MATLAB's documentation for axis properties.

Here is a short example in 2D, you can easily apply this also to 3D:

N = 50;
x = [1:N;N:-1:1];
x = repmat(x,2,1).';
p = plot(x(1),1,'ob','MarkerFaceColor','b');
xlim([0 51])
for k = 2:numel(x)
    p.XData = x(k);
    drawnow
end

The key here is to set xlim before the loop, and then only update the relevant data in the plot (using XData in this case).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!