7
$\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$
10
$\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$
  • 3
    $\begingroup$ I'm glad to see that has been added to the documentation. +1 $\endgroup$ – Mr.Wizard Mar 11 '13 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 Mar 11 '13 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 Mar 11 '13 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 Mar 11 '13 at 19:03
  • $\begingroup$ If I add some text into the figure such as Table[Text[Style[ix, 24, Bold], {ix*unitcellsize, 0, 0}], {ix, 1, 5}] and use Method -> {"ShrinkWrap" -> True}, the number 5 won't appear. What happened in this case? $\endgroup$ – Tony Dong Mar 14 '13 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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