# Box size variation during rotation of 3d data

I have s set 3d data points which I want to rotate, so that the size of the box does not change. Also if possible the window size which contains the plot should not change ist size.

How can I achieve that?

Here is my code:

SeedRandom[1];
data = RandomReal[10, {500, 3}];

Manipulate[
Graphics3D[
{PointSize[Medium], Point[data, VertexColors -> (Hue /@ Rescale[data[[All, 1]]])]},
SphericalRegion -> True, Axes -> True,
AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
ViewProjection -> "Orthographic", Boxed -> True,
AxesLabel -> {"x axis", "y axis", "z axis"},
ViewPoint ->
N @ Dynamic[15*{Sin[α] Cos[β], Sin[α] Sin[β], Cos[α]}], ImageSize -> Small],
{{α, N @ π/3}, N @ π/360, π, π/360, Appearance -> "Labeled"},
{{β, N@π/4}, 0., 2 π, 2 π/360, Appearance -> "Labeled"}]


Result:

• Use clear values ImageSize -> {600, 400} instead of Small.
– Kuba
Commented Dec 13, 2017 at 13:04
• And explicit ImagePadding, like ImagePadding -> {{10, 10}, {10, 10}}. Commented Dec 13, 2017 at 14:03
• Also SphericalRegion -> True helps to avoid the view point depending shifting of the box. Commented Dec 14, 2017 at 13:06
• @Thies SphericalRegion was also my first reaction, but then realized that it was already included among the options. Commented Dec 14, 2017 at 13:53
• @IstvánZachar I see, cool! Didn't notice that. It might still be useful to be aware the parameter exists as a reference for future visitors :) Commented Dec 14, 2017 at 15:36

## 1 Answer

Use ContentSize and Aligment, along with SphericalRegion:

Manipulate[
Graphics3D[{PointSize[Medium],
Point[data, VertexColors -> (Hue /@ Rescale[data[[All, 1]]])]},
SphericalRegion -> True, Axes -> True,
AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},
ViewProjection -> "Ortographic", Boxed -> True,
AxesLabel -> {"x axis", "y axis", "z axis"},
ViewPoint ->
N@Dynamic[
50*{Sin[\[Alpha]] Cos[\[Beta]], Sin[\[Alpha]] Sin[\[Beta]],
Cos[\[Alpha]]}]
],
{{\[Alpha], N@\[Pi]/3}, N@\[Pi]/360, \[Pi], \[Pi]/360,
Appearance -> "Labeled"}, {{\[Beta], N@\[Pi]/4}, 0., 2 \[Pi],
2 \[Pi]/360, Appearance -> "Labeled"},
Alignment -> Center,
ContentSize -> {400, 400},
Initialization :> (SeedRandom[1]; data = RandomReal[10, {500, 3}];)
]


• Thank you for the solution. This works also for e.g. data = Transpose[{RandomReal[10, {500}], RandomReal[5, {500}], RandomReal[2, {500}]}].
– mrz
Commented Dec 15, 2017 at 22:40