Exporting an overlay of two plots

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

Overlay[{p1, Item[Show[p2], Alignment -> {-.7, .6}]}]
Export["graphics.pdf",%]

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.


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}}];

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

enter image description here

You can also inset graphics manually. See:

  • How to insert a plot into another plot

  • How to change the aspect ratio with drawing tool?