I can't find this in the documentation. How do you force the same scale for all the axes when making a 3D plot? There is the BoxRatios
option, but this only changes the dimensions of the visible box with no regard to the actual scales of the axis.
1 Answer
Only BoxRatios
will not solve your problem. You have to fix the PlotRange
also. For example take 2(x^2+y^2)
Plot3D[2 (x^2 + y^2), {x, -1, 1}, {y, -1, 1}, BoxRatios -> 1, FaceGrids -> All]
As you can see the unit along z
direction is twice compared to x
and y
(that's why I choose 2 (x^2 + y^2)
, to make this point)
Now you fix the PlotRange
plrange = {-1, 1};
Plot3D[2 (x^2 + y^2), {x, -1, 1}, {y, -1, 1}, BoxRatios -> 1,
FaceGrids -> All, PlotRange -> {plrange, plrange, plrange + 1}]
And your units are same in all directions.
-
1$\begingroup$ Certainly, an inappropriate setting of
BoxRatios
will not fix OP's problem. Set properly, one will not have to fiddle withPlotRange
unless desired. $\endgroup$ Jul 3, 2015 at 10:08 -
$\begingroup$ It may be worth mentioning explicitly that if you do not want to display a cubic domain, then you can do some math between BoxRatios and PlotRange. Example if you want PlotRange->{ {-a,b},{-c,d},{-h,j} }, then you need BoxRatios->{ a+b, c+d, h+j }. It may also be worth noting that this may be inexact. I can see on my plot that some of the axes are slightly larger than the domain specified by PlotRange. However, it seems to make a nearly unnoticeable visual difference. $\endgroup$– elscanJun 16, 2021 at 11:54
Automatic
and report back. $\endgroup$