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?

  • $\begingroup$ 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 $\endgroup$ – Jason B. Jul 29 '16 at 22:01

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

Mathematica graphics

I just combined two Overlay objects using Show

| improve this answer | |

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

enter image description here

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

  Epilog -> {
    Inset[plotC, Automatic, Automatic, Scaled[{1, 1}]], 
    Inset[inset, Scaled[{0.3, 0.6}]]
| improve this answer | |
  • $\begingroup$ 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. $\endgroup$ – RoderickLee Jul 29 '16 at 21:41
  • $\begingroup$ @RoderickLee Please update your question accordingly. $\endgroup$ – Mr.Wizard Jul 29 '16 at 21:48
  • $\begingroup$ the question is edited $\endgroup$ – RoderickLee Jul 29 '16 at 21:51
  • $\begingroup$ +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. $\endgroup$ – Jason B. Jul 29 '16 at 22:46

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.