0
$\begingroup$

I plot a function with PlotRange -> All called pl1 and again plot the same but this time with PlotRange -> a finite number called pl2. Now I want to show pl1 in large size and pl2 inside it (exactly in top right of it or any arbitrary position) with a small size. A toy example can be

pl1 = Plot[Exp[x], {x, 0, 10}, PlotRange -> All]
pl2 = Plot[Exp[x], {x, 0, 10}, PlotRange -> 50]

How can I do it? I can use GraphicsGrid but I have no idea how to change the size and position of two graphics? BaselinePosition is useless without changing the sizes.

Note that in reality, I have plotted several functions in a single plot and I need to see the points where these functions intersect in a magnified plot (pl2).

$\endgroup$
1
  • 1
    $\begingroup$ Plot[Exp[x], {x, 0, 10}, PlotRange -> All, Epilog -> Inset[ Plot[Exp[x], {x, 0, 4}, PlotRange -> {0, 50}], Scaled[{.4, .6}]]] $\endgroup$
    – Bob Hanlon
    Commented Jan 21, 2022 at 14:55

1 Answer 1

1
$\begingroup$
pl1 = Plot[Exp[x], {x, 0, 10}, PlotRange -> All]
pl2 = Plot[Exp[x], {x, 0, 5}
  , GridLines -> Automatic
  , PlotRange -> 50
  , Background -> Nest[Lighter, Yellow, 3]]

pl3 = Plot[Exp[x]
  , {x, 0, 10}
  , PlotRange -> All
  , GridLines -> Automatic
  , Epilog -> {Inset[pl2, {2, 10000}, {0, 0}]}
  ]

Here (0,0) of the inset plot is aligned with (2,10000) in the main plot.

enter image description here

$\endgroup$
4
  • $\begingroup$ Thanks a lot. and how can I change the position of inner plot arbitrary? for example in the corner of top right? $\endgroup$
    – Wisdom
    Commented Jan 21, 2022 at 15:09
  • 1
    $\begingroup$ Align it to a different point using the scheme shown. There is also a Size parameter in one of the syntax variations. Look at 138354 as well. $\endgroup$
    – Syed
    Commented Jan 21, 2022 at 15:17
  • 1
    $\begingroup$ There is a tutorial as well in the docs. $\endgroup$
    – Syed
    Commented Jan 21, 2022 at 15:23
  • $\begingroup$ Thanks a lot for your help $\endgroup$
    – Wisdom
    Commented Jan 21, 2022 at 15:38

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