# How can I connect the local minimum-value points between a series of curves by dotted lines?

I have a set of data obtained by NDSolve. After I plot it, I want to indicate some feature of the curves. For example, I want to link the local minimum-value points between these curves by dotted line to highlight the track. First, I import the data:

data1 = Import["C:\\Users\\...\\Desktop\\data1.dat"];
data2 = Import["C:\\Users\\...\\Desktop\\data2.dat"];
data3 = Import["C:\\Users\\...\\Desktop\\data3.dat"];


then, plot them

g1 = ListLinePlot[data1];
g2 = ListLinePlot[data2];
g3 = ListLinePlot[data3];
Show[g1, g2, g3, PlotRange -> All]


I get the following plot What I want to do is to link the local min-value point by dashed line. Is there any simply method by Mathematica to do this job? Should I make use of FindMinimum and FindMinValue, but I don't know how to combine them. The objective I want to obtain is as follows which is got by hand:). Yes, as answered by @Oska, whose code can handle many cases. But fail to treat the following case in which there are several local minimum-value points in a single curve. This is the my_data.

Using Oska's code

data1 = Import["C:\\...\\plot1_4sqrt(2)pi.dat"];
data2 = Import["C:\\...\\plot2_4sqrt(2)pi.dat"];
data3 = Import["C:\\...\\plot3_4sqrt(2)pi.dat"];

mins = Function[d,
d[[#]] & /@ (Sort[
First@First@
Position[d, #] & /@ (RankedMin[Last /@ d, #] & /@ {1,
2})])] /@ {data1, data2, data3};
ListLinePlot[{data1, data2, data3},
RotateLeft@(First /@ mins)})[[;; -2]],
RotateLeft@(Last /@ mins)})[[;; -2]]}
]


I will get As can be seen, the code fails to find the local min-value points on the first curve. What I try to get is as follow. I am confusing that why the code can find the local min-value point of the other two curves but fails to the first curve? • You should consider doing a little bit of work and find the minima that you desire on your own. – Öskå Oct 16 '14 at 13:56
• Yes, @Öskå. Thanks a LOT :). But could you give me some hints on why this code can not find the two local min-value points of the first curve but can find that of the other two similar curves. – Enter Oct 16 '14 at 14:42
• You may consider searing on mathematica.SE: see here :) – Öskå Oct 16 '14 at 14:52

I will let you play with the style but here is a beginning:

data1 = Import["~/Downloads/data/data1.dat"];
mins = Function[d,
d[[#]] & /@ (Sort[
First@First@Position[d, #] & /@ (RankedMin[Last /@ d, #] & /@ {1, 2})])] /@
{data1, data2, data3}

ListLinePlot[{data1, data2, data3},
Epilog -> {Red, Line[First /@ mins], Line[Last /@ mins]}] Regarding the series of arrows:

ListLinePlot[{data1, data2, data3},
Epilog -> {Red,
Arrow /@ (Thread@{(First /@ mins), RotateLeft@(First /@ mins)})[[;; -2]],
Arrow /@ (Thread@{(Last /@ mins), RotateLeft@(Last /@ mins)})[[;; -2]]},] • Thanks, @Oska! Is there any possible to add a series of arrows on the redline? I tried this code p0 = ListLinePlot[{data1, data2, data3}, Epilog -> {Red, Dashing[0.02], Line[First /@ mins], Line[Last /@ mins]}];p0 /. Line[x_] :> {Arrowheads[{0, .05, .05, 0}], Arrow[x]}. But I also added arrows on the three curve where I do not need arrow. – Enter Oct 16 '14 at 3:05
• @lxy Please check the update :) – Öskå Oct 16 '14 at 10:09
• Hi,@Oska,thank you for your helpful answer. But it might have a bug. I am confusing that why the code can find the local min-value point of the some curves but fails to the other curves? Could you pls see my post again which has been updated. Thank you for your time! – Enter Oct 16 '14 at 13:54