2
$\begingroup$

This is a follow-up question to (138886).

According to this post, the proper way to export 3D graphics as vector graphics is by inserting them into a 2D regular Graphics as Inset. Now I want the graphics object and its inset to fit the 3D graphics precisely. The previous question was about a lot of white space that often appears around the object. This question is:

How can I set the size of the inset to fit the entire 3D graphics without cropping?

Ideally, a solution would preserve the original 3D graphics size, because things tend to shift and scale disproportionally while rescaling

Here is the example:

plot3d = Plot3D[100,
  {x, 0, 3}, {y, 0, .9},
  BoxRatios -> {3, .9, .5},
  ViewPoint -> {0, -Pi, 1.3},
  ImageSize -> {700, 220}
  ]

enter image description here

And here is what I tried:

Framed[Graphics[Inset[Framed@plot3d]]]

enter image description here

Framed[Graphics[Inset[Framed@plot3d], ImageSize -> {700, 220}]]

enter image description here

Framed[Graphics[Inset[Framed@plot3d]], 
 FrameMargins -> {{50, 50}, {-70, -70}}]

enter image description here

Framed[Graphics[
  Inset[Framed@plot3d, Automatic, Automatic, ImageScaled[1]]]]

enter image description here

$\endgroup$

1 Answer 1

2
$\begingroup$

You have to set the AspectRatio of the Graphics to be consistent with that of the initial Graphics3D, like in:

plot3d = Plot3D[100,
  {x, 0, 3}, {y, 0, .9},
  BoxRatios -> {3, .9, .5},
  ViewPoint -> {0, -Pi, 1.3},
  ImageSize -> {700, 220},
  PlotRange -> All
  ]
Framed @ Graphics[{Inset[Framed@plot3d2]}, AspectRatio -> .9/3, 
 ImageSize -> 700]

enter image description here

$\endgroup$
2
  • $\begingroup$ Yes, thank you!! Do you know why AspectRatio is not already defined by setting width and height explicitly with ImageSize -> {700, 220}? It seems one really needs both. $\endgroup$
    – Felix
    Mar 1, 2017 at 14:59
  • $\begingroup$ @Felix not really I'm afraid. At first I too tried with only ImageSize -> {700, 220} expecting it to work, but to no avail. $\endgroup$
    – glS
    Mar 1, 2017 at 16:46

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.