3
$\begingroup$

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.

$\endgroup$
5
  • 2
    $\begingroup$ Set that option you just found to Automatic and report back. $\endgroup$ Jul 3, 2015 at 8:59
  • $\begingroup$ Shouldn't it be BoxRatios -> 1 ? $\endgroup$
    – Feyre
    Jul 3, 2015 at 9:14
  • $\begingroup$ @Feyre, you can answer your own question by trying to plot a function like $x^2+y^2$. Note the shape of the box, and then note the numbers on the ticks. $\endgroup$ Jul 3, 2015 at 9:34
  • $\begingroup$ @Guesswhoitis. yes that worked, thank you. $\endgroup$
    – Yrogirg
    Jul 3, 2015 at 10:00
  • $\begingroup$ Then, please answer your own question. :) $\endgroup$ Jul 3, 2015 at 10:00

1 Answer 1

4
$\begingroup$

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]

enter image description here

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}]

enter image description here

And your units are same in all directions.

$\endgroup$
2
  • 1
    $\begingroup$ Certainly, an inappropriate setting of BoxRatios will not fix OP's problem. Set properly, one will not have to fiddle with PlotRange 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$
    – elscan
    Jun 16, 2021 at 11:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.