I have a ListLinePlot and I'm trying to place a close-up of a specific range in the ListLinePlot. Using overlay I solved this problem with:

Overlay[{p1, Item[Show[p2], Alignment -> {-.7, .6}]}]

This results in something like the following image:

Overlay example

But I can't select this image and export it. I can do "Print Selection as" and save as pdf, but this rasterizes the image. I want the same resolution as with a normal graphics environment. How do I achieve this?


Although Overlay preserves unrasterized copies of its constituent Graphics it is rasterized by the Front End for the purpose of display. Therefore I do not believe that you can use Overlay for this purpose.

However, I believe you can use Epilog and Inset:

p1 = Plot[Sinc[x], {x, 0, 10}];
p2 = BarChart[{{1, 2, 3}, {1, 3, 2}}];

 ImageSize -> 400,
 Epilog -> Inset[Show[p2, ImageSize -> 150], Scaled[{.6, .6}]]

enter image description here

You can also inset graphics manually. See:

  • $\begingroup$ Thanks, this works! FYI I used Show[p1, Epilog -> Inset[p2, {65, 300}]] in my case. I've seen that it can be done manually, but figured it could be done in mathematica code :). $\endgroup$ – user23127 Jul 28 '14 at 17:41

You can use Export[] when you cannot select outputs in the Front End.

Overlay[{p1, Item[Show[p2], Alignment -> {-.7, .6}]}]

saves the graphics as PDF in your current working directory. No rasterization happens.

This technique can also be used for output of GraphicsRow, GraphicsColumn, and GraphicsGrid where you cannot select whole the graphics.

  • $\begingroup$ You're right! Very interesting. $\endgroup$ – Mr.Wizard Aug 7 '14 at 6:14
  • $\begingroup$ Yes! Tetsuo's solution is much better! $\endgroup$ – Tian Li Feb 17 '17 at 15:26

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.