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},
Epilog -> {Arrowheads[0.02],
Arrow /@ (Thread@{(First /@ mins),
RotateLeft@(First /@ mins)})[[;; -2]],
Arrow /@ (Thread@{(Last /@ mins),
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?