3
$\begingroup$

Something simple like RotationAction->"Clip" doesn't perform the intended change.

Example:

Graph3D[RandomGraph[{20, 30}],
        RotationAction -> "Clip", 
 PlotRegion -> {{0.25, 0.75}, {0.25, 0.75}}]

The user experience with Graph3D seems frustrating to me. The frequent zoom changes are jarring and they do not allow PlotRegion to display as intended. Alternatively, I am unable to specify whether to give some breathing room for the graph, so that it doesn't clip as it rotates.

Am I doing something wrong? is it just buggy?

IMO: An effective platform is created by aesthetic considerations, by cleaning up the loose ends, not by adding more and more pointless detail.

edit:

The PlotRegion specification was copy-pasted from an example in the option's documentation.

By breathing room, I mean padding or margins or range beyond the extent of the graph object.

This is what I see (using the same specifications as Syed). The graph rotation is very smooth but the zoom-level and frame-size keep changing. It would be unusable if, for example, a functional Graph3D object was the main element of a module.

Syed's example is smooth, though. David's example is a still life but I believe that it indeed works flawlessly. I am unsure about the cause for the differences in behavior.

(Running version 12.3.1.0; MacOS)

Updated title.

$\endgroup$
8
  • 2
    $\begingroup$ Works flawlessly for me. (v. 11.3, MacOS). By the way, could you point to one or two of the "pointless details" you rue? $\endgroup$ Commented Aug 26, 2021 at 1:38
  • 1
    $\begingroup$ In spite of the unwarranted attitude and lack of specificity, when moving the RandomGraph the graph immediately jumps, then moves smoothly but when the mouse button is released, the RandomGraph jumps again (back towords the center?) even when SphericalRegion -> True is added. (Windows 10, Mathematica 12.3.0.0) $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 2:33
  • $\begingroup$ What do you mean by 'flawlessly' @DavidG.Stork? When I run the example code (v12.3.1, MacOS), the plot appears very zoomed in. Upon rotation, it zooms out to the specified PlotRegion bounds and zooms back in when rotation stops, despite the RotationAction specifying otherwise. The documentation says that the default "Fit" option "will typically make the graphics appear to jump slightly when the mouse is released," which is occurring. As to your question, I was making a general statement about aesthetics/design, not detailing anything besides the main question. $\endgroup$
    – jWey
    Commented Aug 26, 2021 at 2:35
  • $\begingroup$ See my "answer" below. $\endgroup$ Commented Aug 26, 2021 at 3:56
  • 1
    $\begingroup$ @Adam It's PlotRegion not PlotRange. $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 6:35

4 Answers 4

7
$\begingroup$

The reason why the rotation of Graph3D's output doesn't seem to be controllable with options such as RotationAction or SphericalRegion is that it contains

BaseStyle -> {Graphics3DBoxOptions -> {Method -> {"ShrinkWrap" -> True}}}

You can see it like this:

SeedRandom[3456];
g = Graph3D@RandomGraph[{6, 8}]
Options@Show[g]
{BaseStyle -> {Graphics3DBoxOptions -> {Method -> {"ShrinkWrap" -> True}}},   
 Boxed -> False, FormatType -> TraditionalForm, 
 Lighting -> {{"Directional", GrayLevel[0.7], 
    ImageScaled[{1, 1, 0}]}, {"Point", GrayLevel[0.9], 
    ImageScaled[{0, 0, 0}], {0, 0, 0.07}}}}

I do not know how to disable this directly in Graph3D, but you can disable it when converting a Graph3D to Graphics3D, using

Show[g, BaseStyle -> {}]

You can add other options to Show at the same time, such as RotationAction -> "Clip".


EDIT: @ChipHurst gives the solution in a comment. Use the following:

Graph3D[..., BaseStyle -> {Graphics3DBoxOptions -> {Method -> {"ShrinkWrap" -> False}}}]

It is not sufficient to use

Graph3D[..., BaseStyle -> {}]
$\endgroup$
3
  • 2
    $\begingroup$ Graph3D[RandomGraph[{6, 8}], BaseStyle -> {Graphics3DBoxOptions -> {Method -> {"ShrinkWrap" -> False}}}, RotationAction -> "Clip", PlotRegion -> {{0.25, 0.75}, {0.25, 0.75}}] seems to give the desired behavior. $\endgroup$
    – Greg Hurst
    Commented Aug 26, 2021 at 11:46
  • $\begingroup$ Thank you very much! That creates the intended behavior. And thanks for showing the Options@Show[ g ] way of gathering the options, as I would have assumed it to be the same as Options[ g ]. $\endgroup$
    – jWey
    Commented Aug 26, 2021 at 15:19
  • $\begingroup$ Very good Szabolcs and @ChipHurst! I see that 'Options@Show[g]` for Mathematica 12.2 (Windows 10) does NOT have BaseStyle as an option. So that option appears to have just been added to 12.3 (Windows 10). Possibly the default for future versions of Mathematica might be better changed to have "ShrinkWrap" -> False. $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 15:48
4
$\begingroup$

It works as David G. Stork mentioned.

enter image description here

Second edit:

For the OP command exactly, here is a shot. I used 'Automatic' to save on the white space. I am on version 12.2 on Win7.

enter image description here

Third edit:

JimB is using commands not specified by the OP. And here is a third capture for comparison.

enter image description here

$\endgroup$
5
  • $\begingroup$ Identical to my screen. Indeed: flawless. Whether or not someone accepts the OP's claim (which have NO evidence) and reject my claim. So 100% of the evidence shown on this page proves that the system works flawlessly. Over and out. $\endgroup$ Commented Aug 26, 2021 at 4:42
  • $\begingroup$ What operating system and version of Mathematica? $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 4:58
  • $\begingroup$ Also, those are not the commands that the OP used. $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 5:03
  • $\begingroup$ Ooops! I did leave in ":>" rather than "->" as I tried that, too, but it makes no difference. (I'll modify my answer.) However, when I try it with Mathematica 12.2, it works just like you show it. So maybe it's a 12.3 issue. $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 6:57
  • $\begingroup$ Let's wait for a while, so other 12.3 users on Win10 can share their experience. $\endgroup$
    – Syed
    Commented Aug 26, 2021 at 7:04
2
$\begingroup$

This post just shows the undesired behavior as captured: The scale starts off in the PlotRegion requested but with attempts at rotation results in an immediate rescaling of the graph. Then the rotation is smooth. But once the mouse button is lifted, the graph jumps. (Windows 10, Mathematica 12.3.0.0).

Evidence of jumpiness

$\endgroup$
4
  • $\begingroup$ Use ScreenToGif for smaller capture sizes. $\endgroup$
    – Syed
    Commented Aug 26, 2021 at 6:12
  • $\begingroup$ @Syed. Thank you. I’ll try that. $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 6:36
  • $\begingroup$ @Syed. That works great! Much more compact than what I was using. $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 6:48
  • $\begingroup$ I have this exact behaviour (windows 10 mm12.3) . Szabolcs and Chip Hurst's suggestion does work! $\endgroup$
    – Lou
    Commented Aug 26, 2021 at 13:22
-2
$\begingroup$

The graph rotates flawlessly, without change of scale, position, etc.:

enter image description here

enter image description here

enter image description here

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ How do 4 static frames show that "the graph rotates flawlessly" ? $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 4:11
  • 1
    $\begingroup$ Because I'm telling you that. Geez... Do you actually think it is jumping around, but the static frames all just happen to be perfect? Really? You're turn: Prove to us that the image is showing the flaws that are claimed. Why should we believe you? $\endgroup$ Commented Aug 26, 2021 at 4:16
  • 1
    $\begingroup$ You're right: I'll post an animated gif as evidence. (Mathematica is now in the process of downloading FFmpeg so I can convert a jumpy mp4 to an animated gif). You're wrong: you have shown no evidence. $\endgroup$
    – JimB
    Commented Aug 26, 2021 at 4:36

Your Answer

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

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