I have a few set of data of three dimensional matrices, n x 3 with x, y and z coordinates. I viewed the matrices in the figure window.

% read function;
figure, patch(FV,'facecolor',[0 0 1]); camlight
grid on
axis equal

I want to read other sets of data by using the same function, but sets the center of each figure (not the center of origin) at [x y z]=[0 0 0].

Note that when I use the function above, the center of outputs is not always at [0 0 0].

Is it can be done by using translation function?


1 Answer 1


If you want a perfectly square set of axes with the center at $(0,0,0)$, while keeping all of the data on screen, I'd do something like this:

axis auto;
a = axis;
amax = max(abs(a));

If you like your axes limits to be integral, change max(abs(a)) to ceil(max(abs(a))).

  • $\begingroup$ what if the center of 3D figure is not originally at [0 0 0]? for example: [x y z]=[29.24 -11.83 103]. can i really translate it to be [0 0 0]? $\endgroup$
    – user3991
    Apr 26, 2013 at 3:05
  • $\begingroup$ Well, you've gotta do what looks right. But the purpose of axis auto is to get the extends of the 3-D figure. I use those to determine the smallest cube, centered at the origin, that contains the extents of the figure. $\endgroup$ Apr 26, 2013 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.