Consider a list of lists in this form (with a shape $ m \times n \times 3 $ ):

`{ {{a1, R1, c11}, {a2, R1, c12}, {a3, R1, c13}, ..., {an, R1, c1n}}, {{a1, R2, c21}, {a2, R2, c22}, {a3, R2, c23}, ..., {an, R2, c2n}}, ..., {{a1, Rm, cm1}, {a2, Rm, cm2}, {a3, Rm, cm3}, ..., {an, Rm, cmn}} } `

where in each outer list, the 2nd element $ R_i $ is fixed ($ i = 1, 2, …, m $ ), and the 1st element changes from $ a_1 $ to $ a_n $ , the 3rd element $ c_{ij} $ is normally a complex and its imaginary part can change from positive to negative or from negative to positive for several times. Here is a sample data for test.

I want to pick out the neighbor lists whenever the imaginary part of $ c_{ij} $ changes its sign, say, for $ R_2 $ , the selected lists are something like $ \{a_j, R_2, c_{2j}\} $ and $ \{a_{j+1}, R_2, c_{2,j+1}\} $ , where $ \text{Im} c_{2,j} < 0 $ and $ \text{Im} c_{2,j+1} > 0 $ . More generally, for $ R_p $ I pick out $ \{a_j, R_p, c_{pj}\} $ and $ \{a_{j+1}, R_p, c_{p,j+1}\} $ , and then to plot a curve with `ListLinePlot[{{R1, a01}, {R2, a02}, ..., {Rp, a0p}, ..., {Rm, a0m}}]`

, in which $ a_{0j} = (a_j + a_{j+1}) / 2 $ . In other words, I what to plot a parameter curve w.r.t the 1st and 2nd elements, across which the imaginary part of the 3rd element changes sign.

I tried `Cases`

, `Select`

and `ParametricPlot`

, but I am still having trouble to find all the pairs of the neighboring lists when the imaginary part of $ c_{ij} $ changes its sign.