How can I convert an Overlay into a figure?

Now I’m trying to use

Show[plota, Epilog->Inset[inset, Scaled->[{0.2, 0.7}]]]

operation to insert an inset of a figure, where plota is an Overlay of two plots

plota = Overlay[{plotb, plotc}];

and then I cannot be successfully inserted in because “Overlay is not a type of graphics” so it cannot be showed.

What should I do to make the inset works?

=================

  

 

Head[Graphics@Inset@Overlay[{plotA, plotB}]] === Graphics gives True, so a route to convert an Overlay into a Graphics is to use Inset as an intermediate
– JasonB
Jul 29 at 22:01

=================

2 Answers
2

=================

You can just make everything an Inset, this way you don’t even need an underlying Graphics object to build on top of. Using the plots from Mr. Wizard’s post,

insetA = Overlay[{plotB, plotC}];
insetB = Overlay[{plotA, Graphics@Circle[{0, 0}, .1]}];
Show[Graphics /@ {Inset[insetA, {0, 0}, {0, 0}],
Inset[insetB, Scaled[{-.05, -.05}], {0, 0},
Scaled[{.5, .5}], {1, 1}]}]

I just combined two Overlay objects using Show

As JasonB temporarily commented you can Rasterize an Overlay to convert it into a (rasterized) Graphics expression.

plotB = Plot[2 Sin[x] + x, {x, 0, 15}, Filling -> Bottom];
plotC = Plot[Sinc[x], {x, 0, 10}, PlotStyle -> Green, Axes -> False];

plotA = Overlay[{plotB, plotC}];

inset = Graphics[{Red, Thick, Dashed, Circle[]}];

Show[Rasterize @ plotA,
Epilog -> Inset[inset, Scaled[{0.3, 0.6}]]
]

Doing this you will however loose the scalability of (un-rasterized) vector graphics. You may instead want to Inset repeatedly:

Show[plotB,
Epilog -> {
Inset[plotC, Automatic, Automatic, Scaled[{1, 1}]],
Inset[inset, Scaled[{0.3, 0.6}]]
}
]

  

 

Overlay[{}] is my typo, never mind that. And I also post a wrong question… I actually want to ask what if plota is an Overlay? For Show[] cannot show an Overlay.
– RoderickLee
Jul 29 at 21:41

  

 

@RoderickLee Please update your question accordingly.
– Mr.Wizard♦
Jul 29 at 21:48

  

 

the question is edited
– RoderickLee
Jul 29 at 21:51

  

 

+1 – I erased the Rasterize because I had the inset rasterized, which made the background opaque and looked bad. But if you are rasterizing the bottom layer, it’s better.
– JasonB
Jul 29 at 22:46