Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

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

share|improve this answer
    
Very nice! Is there a way to draw also an arrow pointing form the original position to the zoom? –  Vaggelis_Z May 2 '13 at 16:04
    
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. –  Vaggelis_Z May 2 '13 at 16:05
    
@Vaggelis_Z Both possible, please give it a try. –  b.gatessucks May 2 '13 at 16:06
    
I will! But in any case, I would be very grateful for any suggestions. –  Vaggelis_Z May 2 '13 at 16:09
    
The addition of more ticks in the vertical axis eludes me for now ... –  Vaggelis_Z May 2 '13 at 16:12
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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