0
$\begingroup$

I am doing a numerical experiment for solving some differential equation. In some part I need to plot a graph of the exact and approximated solutions. However, they are very closed to each other and it is difficult to graphically show how the approximated solution is related to the exact one. My question is how I can show the plot in two graphs, one showing the graph with its approximated solution (no problem if t is not clear how they are closed to each other) and another one beside it showing part of this graph in a very short domain in order to graphically represent how they are closed to each other. You can consider y=x^2 as exact solution and we need to show another plot beside the graph of y in a very small domain. I am interested to show the second graph by putting a small box on the graph of y and direct an arrow to the other graph showing this domain that assigned by the square we already constructed. Hope it is clear. looking for your help!

Please look t the plots below. One is for the domain [-1,1] and the other with a small domain and it is clear how the approximated solution behaves.

enter image description here

$\endgroup$
  • $\begingroup$ Why don't you plot their difference? $\endgroup$ – Szabolcs Apr 20 at 18:22
  • $\begingroup$ I did. But I need to show the exact and approximated solution together $\endgroup$ – Mutaz Apr 20 at 18:24
  • $\begingroup$ It can be done with Inset. You can take a look at its documentation page while waiting for someone to post an answer. $\endgroup$ – Szabolcs Apr 20 at 19:05
3
$\begingroup$

Here is a starting for you.

inset = Inset[
   Plot[u^2, {u, 0.05, 0.25}, Frame -> True, 
    FrameTicks -> {{None, All}, {None, All}} , ImageSize -> 150], 
   Scaled[{0.5, 0.7}]];
Show[Plot[x^2, {x, -1, 1}, Frame -> True, Axes -> False, 
  Epilog -> {inset}], 
 Graphics[{FaceForm[], EdgeForm[Black], 
   Rectangle[{0.05, 0}, {0.25, 0.06}], Dashed, GrayLevel[0.5], 
   Line[{{0.05, 0.06}, {-0.42, 0.5}}], 
   Line[{{0.25, 0.06}, {0.3, 0.49}}]}]]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you so much Okkes! $\endgroup$ – Mutaz Apr 21 at 10:05

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.