2
$\begingroup$

Consider a set of data

DataTable ={{0.484785, 0.824468}, {0.48475, 0.696228}, {0.484839, 0.616711}, {0.484929, 0.546276}, {0.485019, 0.483885}, {0.485108, 0.42862}, 

  {0.485563, 0.373584}, {0.486006, 0.3308}, {0.486096, 0.293019}, {0.486186, 0.259553}, {0.486276, 0.229909}, {0.486366, 0.203651}, 

  {0.486455, 0.180392}, {0.486545, 0.159789}, {0.486635, 0.141539}, {0.486725, 0.125374}, {0.486815, 0.111055}, {0.486905, 0.0983712}, 

  {0.486995, 0.0871361}, {0.487085, 0.0771842}, {0.487175, 0.0683689}, {0.487265, 0.0605604}, {0.487356, 0.0536437}, {0.487446, 0.047517}, 

  {0.487536, 0.0420901}, {0.487626, 0.0372829}, {0.48747, 0.0327309}, {0.487659, 1.00471}, {0.488162, 0.0291998}, {0.488253, 0.0258648}, 

  {0.488343, 0.0229108}, {0.488433, 0.0202941}, {0.488523, 0.0179763}, {0.488614, 0.0159232}, {0.488704, 0.0141046}, {0.488794, 0.0124937}, 

  {0.488885, 0.0110668}, {0.488975, 0.00980283}, {0.489066, 0.00868324}, {0.489156, 0.00769152}, {0.489246, 0.00681306}, {0.489337, 0.00603493}, 

  {0.489427, 0.00534568}, {0.489518, 0.00473514}, {0.489971, 0.00415605}, {0.490062, 0.00368138}, {0.490152, 0.00326093}, {0.490243, 0.00288849}, 

  {0.490334, 0.00255859}, {0.490424, 0.00226637}, {0.490515, 0.00200753}, {0.490606, 0.00177825}, {0.490696, 0.00157515}, {0.490787, 0.00139525}, 

  {0.490878, 0.0012359}, {0.490969, 0.00109474}, {0.491059, 0.000969712}, {0.49115, 0.00085896}, {0.491241, 0.000760858}, {0.491332, 0.000673959}, 

  {0.491423, 0.000596986}, {0.491514, 0.000528803}, {0.491604, 0.000468408}, {0.491695, 0.00041491}, {0.491786, 0.000367523}, {0.491538, 0.000317639}, 

  {0.495209, 0.000284014}, {0.495511, 1.01714}, {0.503222, 0.000272958}, {0.503498, 1.01754}, {0.511361, 0.000263783}, {0.511614, 1.01793}, 

  {0.51963, 0.0002553}, {0.519861, 1.01833}, {0.528033, 0.00024709}, {0.528241, 1.01872}, {0.536573, 0.000238665}, {0.536756, 1.01912}, 

  {0.545249, 0.000231105}, {0.545409, 1.01951}, {0.554061, 0.000225248}, {0.5542, 1.01991}, {0.563012, 0.0002202}, {0.563134, 1.0203}, 

  {0.572113, 0.000213867}, {0.572211, 1.0207}, {0.581379, 0.000203594}, {0.581435, 1.02109}, {0.590782, 0.000196652}, {0.590808, 1.02149}, 

  {0.600335, 0.000190423}, {0.600331, 1.02188}, {0.610043, 0.000184299}, {0.610008, 1.02228}, {0.619908, 0.000178462}, {0.619842, 1.02268}, 

  {0.62993, 0.000173069}, {0.629833, 1.02307}, {0.640116, 0.000167587}, {0.639986, 1.02347}, {0.650466, 0.000162523}, {0.650302, 1.02387}, 

  {0.660984, 0.000157375}, {0.660785, 1.02426}, {0.67167, 0.00015262}, {0.671436, 1.02466}, {0.682528, 0.000148231}, {0.68226, 1.02506}, 

  {0.693565, 0.000143464}, {0.693257, 1.02545}, {0.704777, 0.000139268}, {0.704432, 1.02585}, {0.716173, 0.000134925}, {0.715788, 1.02625}, 

  {0.727752, 0.000130848}, {0.727326, 1.02665}, {0.739518, 0.000126957}, {0.73905, 1.02704}, {0.751473, 0.000123244}, {0.750963, 1.02744}, 

  {0.76362, 0.00011976}, {0.763069, 1.02784}, {0.775968, 0.000115967}, {0.775369, 1.02824}, {0.788512, 0.000112632}, {0.787868, 1.02864}, 

  {0.80126, 0.000109283}, {0.800568, 1.02904}, {0.814212, 0.000106193}, {0.813473, 1.02944}, {0.827376, 0.000102985}, {0.826585, 1.02983}, 

  {0.84075, 0.000100073}, {0.83991, 1.03023}, {0.85434, 0.0000972926}, {0.853449, 1.03063}, {0.868152, 0.0000943999}, {0.867206, 1.03103}, 

  {0.882183, 0.0000919152}, {0.881185, 1.03143}, {0.896443, 0.0000892718}, {0.895389, 1.03183}, {0.910933, 0.0000867915}, {0.909823, 1.03223}, 

  {0.925657, 0.0000844223}, {0.924489, 1.03263}, {0.940621, 0.0000819534}, {0.939391, 1.03303}, {0.955822, 0.0000798362}, {0.954534, 1.03343}, 

  {0.971271, 0.0000776959}, {0.969921, 1.03383}, {0.986968, 0.0000756508}, {0.985555, 1.03423}, {1.00292, 0.0000734384}, {1.00144, 1.03463}, 

  {1.01913, 0.0000717207}, {1.01758, 1.03503}, {1.0356, 0.0000696581}, {1.03399, 1.03544}, {1.05233, 0.0000680288}, {1.05066, 1.03584}, 

  {1.06934, 0.0000661387}, {1.06759, 1.03624}, {1.08662, 0.000064527}, {1.0848, 1.03664}, {1.10418, 0.0000629231}, {1.10229, 1.03704}, 

  {1.12203, 0.0000612669}, {1.12006, 1.03744}, {1.14016, 0.000059714}, {1.13811, 1.03785}, {1.15858, 0.0000583466}, {1.15646, 1.03825}, 

  {1.1773, 0.0000568963}, {1.1751, 1.03865}, {1.19632, 0.0000555934}, {1.19404, 1.03905}, {1.21565, 0.0000541843}, {1.21329, 1.03946}, 

  {1.23529, 0.0000530498}, {1.23285, 1.03986}, {1.25525, 0.0000518869}, {1.25272, 1.04026}, {1.27553, 0.0000506733}, {1.27291, 1.04066}, 

  {1.29613, 0.0000496371}, {1.29343, 1.04107}, {1.31707, 0.0000484761}, {1.31428, 1.04147}, {1.33834, 0.0000475086}, {1.33547, 1.04187}, 

  {1.35996, 0.0000464905}, {1.35699, 1.04228}, {1.38193, 0.0000455855}, {1.37887, 1.04268}, {1.40424, 0.000044743}, {1.40109, 1.04309}, 

  {1.42693, 0.000043828}, {1.42368, 1.04349}, {1.44997, 0.0000429749}, {1.44663, 1.0439}, {1.47338, 0.0000423076}, {1.46995, 1.0443}, 

  {1.49718, 0.0000414632}, {1.49364, 1.0447}, {1.52135, 0.0000408603}, {1.51772, 1.04511}, {1.54591, 0.0000402259}, {1.54218, 1.04551}, 

  {1.57087, 0.000039522}, {1.56704, 1.04592}, {1.59623, 0.0000389278}, {1.5923, 1.04632}, {1.62199, 0.0000385159}, {1.61797, 1.04673}, 

  {1.64817, 0.0000379559}, {1.64405, 1.04714}, {1.67478, 0.0000374415}, {1.67055, 1.04754}, {1.7018, 0.0000370639}, {1.69748, 1.04795}, 

  {1.72926, 0.0000366534}, {1.72485, 1.04835}, {1.75716, 0.0000363565}, {1.75265, 1.04876}, {1.78552, 0.0000359358}, {1.7809, 1.04917}, 

  {1.81432, 0.0000357162}, {1.80961, 1.04957}, {1.84358, 0.0000355693}, {1.83878, 1.04998}, {1.87332, 0.0000352635}, {1.86842, 1.05039}, 

  {1.9035, 0.00003549}, {1.89854, 1.05079}, {1.9342, 0.0000352732}, {1.92914, 1.0512}, {1.96592, 0.0000346258}, {1.9881, 0.0000309439}, 

  {1.96024, 1.05161}, {2.0209, 0.00003026}, {1.99184, 1.05202}, {2.05348, 0.0000302566}, {2.02395, 1.05242}, {2.08656, 0.0000304204}, 

  {2.05657, 1.05283}, {2.12022, 0.0000302649}, {2.08972, 1.05324}, {2.15438, 0.0000304135}, {2.12341, 1.05365}, {2.18908, 0.0000306241}, 

  {2.15764, 1.05406}, {2.22434, 0.0000308981}, {2.19242, 1.05446}, {2.26018, 0.0000311121}, {2.22776, 1.05487}, {2.29656, 0.000031564}, 

  {2.26367, 1.05528}, {2.33355, 0.0000318623}, {2.30016, 1.05569}, {2.37111, 0.0000323737}, {2.33723, 1.0561}, {2.40925, 0.0000331084}, 

  {2.37491, 1.05651}, {2.448, 0.0000339106}, {2.41319, 1.05692}, {2.48736, 0.0000347845}, {2.45209, 1.05733}, {2.52738, 0.000035467}, 

  {2.49162, 1.05774}, {2.56801, 0.0000364906}, {2.53178, 1.05815}, {2.6093, 0.0000375061}, {2.57259, 1.05856}, {2.65124, 0.0000386853}, 

  {2.61406, 1.05897}, {2.69381, 0.0000403238}, {2.6562, 1.05938}, {2.73705, 0.000042116}, {2.69902, 1.05979}, {2.78105, 0.0000433749}, 

  {2.74253, 1.0602}, {2.82572, 0.0000449634}, {2.78673, 1.06061}, {2.8711, 0.0000467739}, {2.83165, 1.06102}, {2.9172, 0.0000487061}, 

  {2.8773, 1.06143}, {2.96405, 0.0000506674}, {2.92368, 1.06184}, {3.01167, 0.0000524967}, {2.97081, 1.06226}, {3.06007, 0.0000542287}, 

  {3.0187, 1.06267}, {3.10925, 0.0000559617}, {3.06736, 1.06308}, {3.15924, 0.0000574327}, {3.1168, 1.06349}, {3.21004, 0.000059031}, 

  {3.16704, 1.0639}, {3.26166, 0.0000605827}, {3.2181, 1.06432}, {3.3141, 0.0000622687}, {3.26997, 1.06473}, {3.36738, 0.0000640336}, 

  {3.32268, 1.06514}, {3.42149, 0.0000661463}, {3.37624, 1.06555}, {3.47647, 0.0000683287}, {3.43067, 1.06597}, {3.53232, 0.0000707956}, 

  {3.48597, 1.06638}, {3.58905, 0.0000736094}, {3.54216, 1.06679}, {3.64669, 0.0000764967}, {3.59926, 1.06721}, {3.70524, 0.0000798165}, 

  {3.65728, 1.06762}, {3.76471, 0.0000834894}, {3.71623, 1.06803}, {3.82514, 0.0000873313}, {3.77613, 1.06845}, {3.88652, 0.0000915333}, 

  {3.837, 1.06886}, {3.94886, 0.0000963229}, {3.89886, 1.06928}, {4.0122, 0.000101516}, {3.9617, 1.06969}, {4.07654, 0.000107257}, {4.02556, 1.07011}, 

  {4.14188, 0.000113664}, {4.09046, 1.07052}, {4.20824, 0.000121301}, {4.15639, 1.07093}, {4.27561, 0.000130168}, {4.22339, 1.07135}, 

  {4.34401, 0.000140948}, {4.29147, 1.07176}, {4.41342, 0.000154391}, {4.36065, 1.07218}, {4.48386, 0.000171334}, {4.43094, 1.0726}, 

  {4.55203, 0.00019224}, {4.50236, 1.07301}, {4.61449, 0.000216568}, {4.57494, 1.07343}, {4.67437, 0.00024562}, {4.64869, 1.07384}, 

  {4.73498, 0.000280281}, {4.72362, 1.07426}, {4.79079, 0.000320334}, {4.8375, 0.000361259}, {4.79976, 1.07521}, {4.87893, 0.000410179}, 

  {4.91439, 0.000464428}, {4.87722, 1.0633}, {4.88886, 0.929875}, {4.88977, 0.823673}, {4.89067, 0.7296}, {4.89158, 0.646272}, {4.89248, 0.57246}, 

  {4.89339, 0.507079}, {4.89429, 0.449165}, {4.89519, 0.397865}, {4.8961, 0.352425}, {4.89701, 0.312174}, {4.89791, 0.27652}, {4.89882, 0.244938}, 

  {4.89972, 0.216964}, {4.90063, 0.192184}, {4.90153, 0.170234}, {4.90244, 0.150792}, {4.90335, 0.13357}, {4.90425, 0.118314}, {4.90516, 0.104802}, 

  {4.90607, 0.0928321}, {4.90697, 0.0822297}, {4.90788, 0.0728381}, {4.90879, 0.0645192}, {4.9097, 0.0571504}, {4.9106, 0.0506232}, 

  {4.91151, 0.0448414}, {4.91242, 0.0397201}, {4.91333, 0.0351836}, {4.91424, 0.0311652}, {4.91514, 0.0276058}, {4.91605, 0.0244529}, 

  {4.91696, 0.0216601}, {4.91787, 0.0191863}, {4.91878, 0.016995}, {4.91969, 0.015054}, {4.9206, 0.0133347}, {4.92151, 0.0118117}, 

  {4.92242, 0.0104627}, {4.92333, 0.00926771}, {4.92424, 0.00820923}, {4.92515, 0.00727164}, {4.92606, 0.00644114}, {4.92697, 0.00570549}, 

  {4.92788, 0.00505386}, {4.92879, 0.00447665}, {4.9297, 0.00396537}, {4.93062, 0.00351248}, {4.93153, 0.00311132}, {4.93244, 0.00275597}, 

  {4.93335, 0.00244121}, {4.93426, 0.00216239}, {4.93518, 0.00191542}, {4.93609, 0.00169666}, {4.937, 0.00150288}, {4.93791, 0.00133124}, 

  {4.93883, 0.0011792}, {4.93974, 0.00104452}, {4.94065, 0.000925222}, {4.94157, 0.000819552}, {4.94248, 0.00072595}, {4.94339, 0.000643038}, {4.94814, 0.000552088}, {4.93442, 0.000506373}, {4.92348, 1.06943}} 

It corresponds to some contour. When I'm trying to plot it using ListLogLogPlot, it shows the contour correctly, but when I'm trying to use the option Joined->True, then instead of joining the point-neighbors it joins points located very far from each others.

What is the reason for this and how to avoid it?

$\endgroup$
2
  • $\begingroup$ I guess it was not you, who sorted the list of points by the first coordinate? Usually software tools would already give you the list in a meaningful order, such that you can just connect them in the order given in the list of points. $\endgroup$
    – Johu
    Aug 24, 2018 at 7:52
  • $\begingroup$ @Johu : I used web plot digitizer with the option "Sort by the nearest neighbors", but this didn't help. $\endgroup$ Aug 24, 2018 at 8:45

1 Answer 1

6
$\begingroup$

Update: Stitching multiple paths produces by FindCurvePath into a single path:

ClearAll[chain, stichPaths]
chain = # //. 
  {a___, p1 : {b_, ___}, c___, p2 : {b_, ___}, e___} :> {a, Reverse @ p1, p2, c, e} //. 
  {a___, p1 : {___, b1_}, c___, p2 : {___, b2_}, e___} /; Abs[b1 - b2] <= 1 :> 
     {a, p1, Reverse @ p2, c, e} &;

stichPaths[data_] := Module[{pts = data[[#]] & /@ FindCurvePath[data], nFs, range, path, 
   newpts},
  range = Range[Length@pts];
  nFs = Nearest /@ (Join @@ Drop[pts[[All, {1, -1}]], #] & /@ range);
  newpts = Join @@ (Join[nFs[[#]][ pts[[#, 1]]], pts[[#]], 
        nFs[[#]][ pts[[#, -1]]]] & /@ range);
  path = Append[#, #[[1]]] &[Join @@ (chain@FindCurvePath[newpts])]; 
  newpts[[path]]]

ListLogLogPlot[stichPaths[DataTable], Joined -> True]

enter image description here

Original answer:

Re-ordering the input data using FindShortestTour seems to work:

ListLogLogPlot[DataTable, Joined -> True]

enter image description here

ListLogLogPlot[DataTable[[FindShortestTour[DataTable][[2]]]], Joined -> True]

enter image description here

You can also use ListCurvePathPlot and FindCurvePath

pts1 =  Cases[ListCurvePathPlot[DataTable], Line[x_] :> x, Infinity];
ListLogLogPlot[pts1, Joined -> True]

enter image description here

pts2 = DataTable[[#]] & /@ FindCurvePath[DataTable];
ListLogLogPlot[pts2, Joined -> True]

same picture

Both need further processing to get a single curve.

$\endgroup$
2
  • $\begingroup$ Thank you very much! Your answer helped me. However, when I'm trying to apply this method to another set of data, it joints most of the points correctly, but there are few points which are connected not in a shortest way. How do you think, is there any general reason for this? $\endgroup$ Aug 23, 2018 at 23:21
  • 1
    $\begingroup$ I have found the reason. My second data have very small distance between y coordinates, smaller than between x. However, the values y themselves are very small. Therefore such option helped: DataTable[[FindShortestTour[{#[[1]], Log10[#[[2]]]} & /@DataTable][[2]]]] $\endgroup$ Aug 24, 2018 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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