10
$\begingroup$

If the option Boxed is set to be False in Graphics3D, additional white margins may appear as shown in the following figure. Is it possible to remove the useless margins such that the borders touch the contents?

smallarray = 
 With[{L0 = 300, r0 = 50, unitcellsize = 400, origin = {0, 0, 0}, 
   la = 800, ra = 50 },
  Graphics3D[{EdgeForm[None], Yellow, 
    Table[{Cylinder[{{ix*unitcellsize, iy*unitcellsize - L0/2, 
         0}, {ix*unitcellsize, iy*unitcellsize + L0/2, 0}}, r0]}, {ix,
       1, 5}, {iy, 1, 5}], Arrowheads[0.1], Red, 
    Arrow[Tube[{origin, origin + {la, 0, 0}}, ra]], Magenta, 
    Arrow[Tube[{{0, 0, 0}, origin + {0, la, 0}}, ra]], Cyan, 
    Arrow[Tube[{origin, origin + {0, 0, la}}, ra]]}, Boxed -> False, 
   Lighting -> Automatic, ViewPoint -> {Pi, Pi/2, Pi}, 
   ImageSize -> {Automatic, 400}]]

enter image description here

$\endgroup$
2

1 Answer 1

16
$\begingroup$

The option you need is Method->{"ShrinkWrap"->True}. From the Documentation Center Graphics3D>Options>Method:

By default, empty space may appear around a graphical image ..
Use Method->{"ShrinkWrap"->True} to prevent the inclusion of empty space.

smallarray = 
 With[{L0 = 300, r0 = 50, unitcellsize = 400, origin = {0, 0, 0},  la = 800, ra = 50}, 
 Graphics3D[{EdgeForm[None], Yellow, 
 Table[{Cylinder[{{ix*unitcellsize, iy*unitcellsize - L0/2, 
     0}, {ix*unitcellsize, iy*unitcellsize + L0/2, 0}}, r0]},
  {ix,  1, 5}, {iy, 1, 5}], Arrowheads[0.1], Red, 
 Arrow[Tube[{origin, origin + {la, 0, 0}}, ra]], Magenta, 
 Arrow[Tube[{{0, 0, 0}, origin + {0, la, 0}}, ra]], Cyan, 
 Arrow[Tube[{origin, origin + {0, 0, la}}, ra]]}, Boxed -> False, 
 Lighting -> Automatic, ViewPoint -> {Pi, Pi/2, Pi}, 
 ImageSize -> {Automatic, 400}, PlotRangePadding -> 0, 
 ImagePadding -> 0, Method -> {"ShrinkWrap" -> True}]]

enter image description here enter image description here

$\endgroup$
6
  • 3
    $\begingroup$ I'm glad to see that has been added to the documentation. +1 $\endgroup$
    – Mr.Wizard
    Commented Mar 11, 2013 at 8:25
  • $\begingroup$ By the way, I see that your avatar is changing with your IP address again. Why did you remove the email from your profile? $\endgroup$
    – Mr.Wizard
    Commented Mar 11, 2013 at 8:26
  • $\begingroup$ @Mr.Wizard, just added my e-mail to my profile (was confused about public visibility of the e-mail address in the profile:) $\endgroup$
    – kglr
    Commented Mar 11, 2013 at 8:52
  • $\begingroup$ @kguler The email and real name fields are not publicly visible. You can check what is visible publicly by viewing your profile using an incognito session in Chrome (or its equivalent in FF/Safari/Opera/IE) $\endgroup$
    – rm -rf
    Commented Mar 11, 2013 at 19:03
  • 2
    $\begingroup$ @kglr: You MUST work for WRI... you simply know too damn much! So very helpful. (+1) $\endgroup$ Commented Apr 16, 2019 at 3:52

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.