I have a 3d-plot in MATLAB composed of many 3d-lines (by line([...],[...],[...],...)
). If I rotate the plot with mouse and the rotate-tool (clickable icon in figure-window) MATLAB rescales the axis all the time. I know that it is possible to manually adjust the axis limits by using axis([...])
, but I dont know the min/max-values of the 3d-lines, or surface objects.
You can test it for yourself by typing surf(peaks)
. The axis are constantly changing between 0-50 and 0-60. I am using R2011a.
Do you have any suggestions how to get the 3d-min/max values of composed 3d-lines/3d-surface-meshes, to be able to set the axislimits manually?
Thanks
I think you've not discovered the command axis
yet. From the documentation:
axis vis3d
Freeze the aspect ratio properties. Sets the plot box aspect ratio mode and data aspect ratio mode properties to manual.
Example:
> surf(peaks);
> axis vis3d
...no more random axis scaling changes.
If you really need to extract the min/max of the data (rare cases), you can use something along the following lines:
plots = get(gca, 'children');
zdata = get(plots, 'zdata');
if isscalar(plots)
zdata = {zdata}; end
maxZ = cellfun(@(x)max(x(:)), zdata);
minZ = cellfun(@(x)min(x(:)), zdata);