5
$\begingroup$

As the title indicates, I want to add inside the main plot (preferably at the lower left part) a zoom. Here is the corresponding Mathematica code:

Clear["Global`*"];  
Off[General::spell];

Vd = -(Md/Sqrt[b^2 + R^2 + (a + Sqrt[h^2 + z^2])^2]);
Vn = -(Mn/Sqrt[R^2 + z^2 + cn^2]);
Vper = k*R^3 + λ*(R^2 + β*z^2)^2;
Vtot = Vd + Vn + Vper;
Veff = Vtot + Lz^2/(2*R^2);

Md = 12000; b = 8; a = 3; h = 0.1;
Mn = 400; cn = 0.25;
k = -0.35; λ = 0.01; β = 0.01;
Lz = 20;
E0 = -1100;

C0 = ContourPlot[Veff, {R, 0.001, 35}, {z, -80, 80}, Contours -> {E0},
PlotPoints -> 200, ContourShading -> False, 
ContourStyle -> {Black, Thickness[0.003]}, 
PerformanceGoal -> "Quality", ImageSize -> 550];

SetDirectory[" ... "];
data = ReadList["orb_RR.out", Number, RecordLists -> True];
S0 = ListPlot[Flatten[List /@ data[[All, {2, 3}]], 1], Joined -> True, 
PlotStyle -> Darker[Gray]];

P0 = Show[{C0, S0}, Frame -> True, FrameLabel -> {"R", "z"}, 
RotateLabel -> False, Axes -> False, 
FrameStyle -> Directive[FontSize -> 17, FontFamily -> "Helvetica"], 
 PlotRange -> {{0, 35}, {-80, 80}}, ImageSize -> 550]
P1 = Show[{C0, S0}, Frame -> True, FrameLabel -> {"R", "z"}, 
RotateLabel -> False, Axes -> False, 
FrameStyle -> Directive[FontSize -> 17, FontFamily -> "Helvetica"], 
PlotRange -> {{0.3, 4.5}, {-5, 5}}, ImageSize -> 550]

The main plot which is produced by P0 is the following

enter image description here

Obviously, it is impossible to understand and interpret the orbit which is inside the closed curve. One may argue, that this issue could be easily solved by just changing the ranges of plot. However, this is not very wise approach, since I need to present the entire area defined by the closed curve and then point out that the orbit is indeed confined only at a very small sub-area. So, I have to incorporate the zoom plot created by P1

enter image description here

using the specified ranges preferably at the lower left side of the main plot (where there is plenty of available space). It would be very nice if there were also arrows pointing the original position of the zoom.

The file containing the orbit data can be downloaded from here:

enter link description here

Any ideas on how this could be done?

Many thanks in advance!

$\endgroup$

1 Answer 1

12
$\begingroup$

You could use Epilog in the main plot to Inset the zoomed graph :

P2 = Show[{C0, S0}, Frame -> True, FrameLabel -> {"R", "z"}, 
  RotateLabel -> False, Axes -> False, 
  FrameStyle -> Directive[FontSize -> 17, FontFamily -> "Helvetica"], 
  PlotRange -> {{0.3, 4.5}, {-5, 5}}]

Show[ContourPlot[Veff, {R, 0.001, 35}, {z, -80, 80}, Contours -> {E0},
 PlotPoints -> 200, ContourShading -> False, 
 ContourStyle -> {Black, Thickness[0.003]}, 
 PerformanceGoal -> "Quality", ImageSize -> 550, 
 Epilog -> Inset[P2, {5, 45}, Automatic, 15], 
 FrameTicks -> {{Range[-100, 100, 10], Automatic}, {Automatic, Automatic}}], 
 ListPlot[Flatten[List /@ data[[All, {2, 3}]], 1], Joined -> True, 
 PlotStyle -> Darker[Gray]]]

enter image description here

$\endgroup$
6
  • $\begingroup$ Very nice! Is there a way to draw also an arrow pointing form the original position to the zoom? $\endgroup$
    – Vaggelis_Z
    May 2, 2013 at 16:04
  • $\begingroup$ A minor issue... At the main plot how could add more ticks at the vertical axis? Now there is only -50 and 50. It could be better if we had 10, 20, 30, etc. $\endgroup$
    – Vaggelis_Z
    May 2, 2013 at 16:05
  • $\begingroup$ @Vaggelis_Z Both possible, please give it a try. $\endgroup$ May 2, 2013 at 16:06
  • $\begingroup$ I will! But in any case, I would be very grateful for any suggestions. $\endgroup$
    – Vaggelis_Z
    May 2, 2013 at 16:09
  • $\begingroup$ The addition of more ticks in the vertical axis eludes me for now ... $\endgroup$
    – Vaggelis_Z
    May 2, 2013 at 16:12

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.