# Remove the white space bounding a 3D plot

The following simple 3D plot always bears a rather wide empty space surrounding the sphere. I only need the sphere and vectors without box or axes. How to remove/control the empty space?

A few padding options I tried do not seem to help. And nonzero PlotRangePadding seems necessary to have a few vectors not cut at the boundary.

m = 1.1;
SliceVectorPlot3D[{y, -x, z},
x^2 + y^2 + z^2 == 1, {x, -m, m}, {y, -m, m}, {z, -m, m},
VectorPoints -> 5, VectorSizes -> 0.9, ViewPoint -> {0.1, -2, 2},
ViewVertical -> {-1, 0., 0.}, Boxed -> False, Axes -> False,
ImageSize -> Medium]


The default PlotRange setting for SliceVectorPlot3D is {Full, Full, Full} (see the Details and Options section). This means that the full regions of space corresponding to the specified variable ranges will be shown, including any portions in which your function has no plot. The latter will show up as empty space.

To restrict the plot to the minimum calculated range that just includes the function's plot, you want PlotRange -> All instead. Add that option (and perhaps remove all the other padding, margins etc) to minimize white space:

m = 1.1;
SliceVectorPlot3D[
{y, -x, z}, x^2 + y^2 + z^2 == 1,
{x, -m, m}, {y, -m, m}, {z, -m, m},
PlotRange -> All,
Axes -> False, Boxed -> False
VectorPoints -> 5, VectorSizes -> 0.9
]


To explain the difference between Full and All in the context of PlotRange, I find these two examples pretty clear:

Plot[Sqrt[x], {x, -3, 3}, PlotRange -> #]& /@ {Full, All}


In the plot on the left, the entire $$-3 range is shown even though nothing can be plotted in the negative $$x$$ region because the function is complex-valued there. In the plot in the right, the plot range is restricted to only include the values of x for which a plot is generated (i.e. $$x\geq 0$$.

• Saved my day. Thank you! Commented Jun 13, 2022 at 4:39
• @xiaohuamao Glad it helped! Thank you for the accept as well. Commented Jun 13, 2022 at 11:51

Another possibility is to use Method -> {"ShrinkWrap" -> True} (previously featured e.g. here):

With[{m = 1.1},
SliceVectorPlot3D[{y, -x, z}, x^2 + y^2 + z^2 == 1,
{x, -m, m}, {y, -m, m}, {z, -m, m},
VectorPoints -> 5, VectorSizes -> 0.9, ViewPoint -> {0.1, -2, 2},
ViewVertical -> {-1, 0., 0.}, Boxed -> False, Axes -> None,
PlotRangePadding -> Automatic, ImageSize -> Medium,
Method -> {"ShrinkWrap" -> True}]]


• Interesting! Never heard of it. Commented Jun 14, 2022 at 0:45