10
$\begingroup$

This has always bugged me and wondering if there is a fix.

When I evaluate a Plot3D I get a graph as expected. However, when I click the graph with the mouse it resizes to a smaller size. I can then rotate it freely. I find this behavior strange. I illustrated this in the gif below.

In addition, notice that if I evaluate Plot3D again, the image doesn't reset to the big size. I find this strange as well. Shouldn't it resize to big? I illustrated this toward the end of the gif.

  1. Can you explain why the image resizes to small upon clicking it with the mouse? What's the point of this?

  2. Can you explain why the image does not resize to large upon evaluating Plot3D the second time as shown in the gif? This doesn't make sense why it wouldn't reset like everything else.

  3. Is there a way to evaluate Plot3D in such a way that I get a fixed size graph that does not change when it is initially clicked by the mouse?

Thank you! I'm relatively new to Stack Exchange. Please let me know if there is anything I am doing that is not following protocol. Thank you!

Why does Plot3D Resize when clicked?

enter image description here

[![enter image description here][3]][3]

enter image description here

$\endgroup$
12
  • $\begingroup$ I'm on a mobile right now, so I can't test... But does specifying an ImageSize solve the issue? It's an option for Plot and the like $\endgroup$
    – Lukas
    Sep 20, 2015 at 20:14
  • $\begingroup$ Thanks Lukas. I tried that but didn't help. However, I noticed that if I added the option SphericalRegion->True I almost get what I want. See 2nd gif above. You'll notice it still moved the graph ever so slightly to the left when initially clicked. I would like no change at all. $\endgroup$
    – B flat
    Sep 20, 2015 at 20:21
  • $\begingroup$ So I did so more digging and may have answered my own question. If I add ImagePadding->1 and SphericalRegion->True for options it seems to work. It there a more efficient way? It seems like aesthetically the default option should be no resizing or shifting. $\endgroup$
    – B flat
    Sep 20, 2015 at 20:33
  • $\begingroup$ Have you tried the option RotationAction->"Clip"? I think this option without the others about would do it. $\endgroup$
    – Edmund
    Sep 20, 2015 at 20:52
  • $\begingroup$ Hi Edmund. Interesting. The RotationAction->Clip option fixes the initial resize action but the moment you try rotating the graphic the size jumps to a smaller size again. It looks like my solution above still stands. Any other ideas? $\endgroup$
    – B flat
    Sep 20, 2015 at 20:56

1 Answer 1

4
$\begingroup$

If you use both options and put Clip in double quotes, it works as desired. (Windows 7, Mathematica 10.2).

Plot3D[Sin[x y], {x, -3, 3}, {y, -3, 3}, RotationAction -> "Clip", SphericalRegion -> True]
$\endgroup$
4
  • $\begingroup$ Thank you. I did forget the quotes. : / I tried the quotes and I'm getting a slight move to the left still. My only fix so far is to add ImagePadding->1. I'm running Mathematica 10.2 now. It seems this may be compatibility issue in OS X. I added a gif using your code and what I see above. @Jim $\endgroup$
    – B flat
    Sep 20, 2015 at 21:58
  • $\begingroup$ @MichaelMcCain. Well, maybe I overstated with "works as desired." No resizing but there is the small shift to the left as you describe (again with Windows 7 and Mathematica 10.2 - so probably not an OS X issue). Adding in ImagePadding -> 1 does complete things as you suggested. $\endgroup$
    – JimB
    Sep 20, 2015 at 22:42
  • $\begingroup$ @MichaelMcCain. I think I need to withdraw my answer. It appears that just SphericalRegion->True is needed to keep things from resizing on the first time executing with a fresh kernel. The small shift to the left only occurs the first time one executes the command. That coupled with the position drawn being the same from what remained from the previous execution suggests that some parameter is not being initialized on the first execution. This would seem to call for folks more knowledgeable about the inner workings of Mathematica than me (which is nearly everybody). $\endgroup$
    – JimB
    Sep 20, 2015 at 23:07
  • $\begingroup$ Thank you for troubleshooting with me. @Jim $\endgroup$
    – B flat
    Sep 21, 2015 at 4:05

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.