1
$\begingroup$

If this is trivial or a duplicate I apologize. I failed to find something.

I have the following code

g1 = Graphics3D[{Gray, Specularity[White, 60], Opacity[0.5], 
      Scale[#, {10, 3, 2}], Opacity[1], Scale[#, {.001, 3, 2}]} &@
    Sphere[], Axes -> True];
g2 = Graphics3D[{Thick, {Arrowheads[Medium], 
     Arrow[{{0, 0, 0}, {10, 0, 0}}], Arrow[{{0, 0, 0}, {0, 0, 2}}], 
     Arrow[{{0, 0, 0}, {0, -3, 0}}]}}];
Rasterize[
 Show[{g1, g2}, Boxed -> False, Axes -> False, ImagePadding -> None, 
  ImageMargins -> None, 
  PlotRange -> {{-10.1, 10.1}, {-3.1, 3.1}, {-2.1, 2.1}}, 
  ImageSize -> 600, Lighting -> "Neutral"], ImageResolution -> 200]

which produces the following figure. enter image description here

When I insert this figure in Latex I take something likeenter image description here

As you see there is a lot of space between the caption and the figure. How is it possible to decrease these "white margins"? In order to be more clear see the following figure. enter image description here

Thanks.

$\endgroup$
6
  • $\begingroup$ So do you want bounding box or not? With Boxed->False you can just add ImageCrop. $\endgroup$
    – Kuba
    Nov 19, 2015 at 11:22
  • $\begingroup$ Sorry. I edited the question. $\endgroup$
    – Dimitris
    Nov 19, 2015 at 11:29
  • 3
    $\begingroup$ Have you tried Method -> {"ShrinkWrap" -> True}? $\endgroup$ Nov 19, 2015 at 11:29
  • $\begingroup$ @J.M.: No! Thanks. $\endgroup$
    – Dimitris
    Nov 19, 2015 at 11:32
  • 2
    $\begingroup$ If it worked, could you answer your own question? $\endgroup$ Nov 19, 2015 at 11:41

1 Answer 1

1
$\begingroup$

The following will do what I wanted (thanks to @Kuba and @J.M.)

g1 = Graphics3D[{Gray, Specularity[White, 60], Opacity[0.5], 
      Scale[#, {10, 3, 2}], Opacity[1], Scale[#, {.001, 3, 2}]} &@
    Sphere[], Axes -> True];
g2 = Graphics3D[{Thick, {Arrowheads[Medium], 
     Arrow[{{0, 0, 0}, {10, 0, 0}}], Arrow[{{0, 0, 0}, {0, 0, 2}}], 
     Arrow[{{0, 0, 0}, {0, -3, 0}}]}}];
Rasterize[
 Show[{g1, g2}, Boxed -> False, Axes -> False, ImagePadding -> None, 
  ImageMargins -> None, 
  PlotRange -> {{-10.1, 10.1}, {-3.1, 3.1}, {-2.1, 2.1}}, 
  ImageSize -> 600, Lighting -> "Neutral", 
  Method -> {"ShrinkWrap" -> True}], ImageResolution -> 300]

or

g1 = Graphics3D[{Gray, Specularity[White, 60], Opacity[0.5], 
      Scale[#, {10, 3, 2}], Opacity[1], Scale[#, {.001, 3, 2}]} &@
    Sphere[], Axes -> True];
g2 = Graphics3D[{Thick, {Arrowheads[Medium], 
     Arrow[{{0, 0, 0}, {10, 0, 0}}], Arrow[{{0, 0, 0}, {0, 0, 2}}], 
     Arrow[{{0, 0, 0}, {0, -3, 0}}]}}];
ImageCrop[
 Rasterize[
  Show[{g1, g2}, Boxed -> False, Axes -> False, ImagePadding -> None, 
   ImageMargins -> None, 
   PlotRange -> {{-10.1, 10.1}, {-3.1, 3.1}, {-2.1, 2.1}}, 
   ImageSize -> 600, Lighting -> "Neutral", 
   Method -> {"ShrinkWrap" -> True}], ImageResolution -> 300]]

Both result to the same output.

enter image description here

$\endgroup$

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.