4
$\begingroup$

If I have to figure done as in the following format:

Figure1= Show[....(*Several figures*)....]
Figure2=Show[....(*Several figures*).....]

Questions:

  1. How can I put Figure2 as an inset of Figure1?
  2. How can I specify the size and where Figure2 will go in Figure1

I tried using the following but it plots both figures on top of each other (showing mostly Figure1):

Show[Figure1, Epilog -> {Inset[Figure2]}]

I also tried using what I found here: How to insert a plot into another plot but it didn't work for me, perhaps because of Show?

Thanks,

$\endgroup$
4
  • $\begingroup$ Use Show[Figure1, Graphics@Inset[Figure2, ....]] $\endgroup$
    – MarcoB
    Commented Jan 3, 2021 at 23:10
  • $\begingroup$ @MarcoB this seems to give the same result than Show[Figure1, Epilog -> {Inset[Figure2]}]. I guess it can work by reducing the size of Figure2 but ImageSize is not suitable in this case. Also by using a command to place it in a given location $\endgroup$
    – John
    Commented Jan 3, 2021 at 23:18
  • 1
    $\begingroup$ Not sure that I understand; I posted an example in the answer below. See if that clarifies what I meant. If that doesn't work, you might have to share the exact structure of the two Figures you have. $\endgroup$
    – MarcoB
    Commented Jan 3, 2021 at 23:24
  • $\begingroup$ @MarcoB thanks for the clarification! it helped a lot ! $\endgroup$
    – John
    Commented Jan 3, 2021 at 23:32

1 Answer 1

7
$\begingroup$

Two sample graphics generated by combining plots with Show:

fig1 = Show[Plot[Style[Sin[x], Red], {x, -2, 2}], Plot[Style[Cos[x], Red], {x, -2, 2}]];
fig2 = Show[Plot[Style[x^2, Blue], {x, -2, 2}], Plot[Style[-x^2 + 2, Blue], {x, -2, 2}]];

Let's combine them by inlaying the second one into the first one, with control over size, relative position, and placement:

Show[
  fig1,
  Graphics@Inset[fig2, {-1.5, -0.3}, {Left, Bottom}, Scaled[1/3]]
]

combined graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.