ListPlot join points by nearest neighbor rather than order Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Interpolation on large 2D list results in erratic functionHow can I combine several 2D-plots to one big 3D plot?ListContourPlot3D blank box?Does anyone know a way to draw lines connecting nearest neighbor points in ListPlot[ ]?PlotRange->Automatic the exact function used to calculate outliersI need help on plotting surface through my list of data pointsHow do I make ListPlot join the points in order?ListContourPlot not plotting all data pointsMathematica returns a blank coordinate system when I try to plot dataMore resolution on ListContourPlot?

The logistics of corpse disposal

What would be Julian Assange's expected punishment, on the current English criminal law?

Do I really need recursive chmod to restrict access to a folder?

What LEGO pieces have "real-world" functionality?

List numbering with letters

Why does Python start at index 1 when iterating an array backwards?

Can a drone be seen on TCAS?

Sorting numerically

Could transporting electricity using plastic water pipes be feasible?

What is the longest distance a 13th level monk can jump while attacking on the same turn?

Is it true that "carbohydrates are of no use for the basal metabolic need"?

Is there a concise way to say "all of the X, one of each"?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

Stars Make Stars

He is picky about food(,) so he only eats what he likes

Do we know the consistency strength of the Singular Cardinal Hypothesis failing on an uncountable cofinality?

How to draw this diagram using TikZ package?

What do you call a plan that's an alternative plan in case your initial plan fails?

How can I make names more distinctive without making them longer?

Are variable time comparisons always a security risk in cryptography code?

Can a zero nonce be safely used with AES-GCM if the key is random and never used again?

Who can trigger ship-wide alerts in Star Trek?

Left action of a group on permutation representation

How do I keep my slimes from escaping their pens?



ListPlot join points by nearest neighbor rather than order



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Interpolation on large 2D list results in erratic functionHow can I combine several 2D-plots to one big 3D plot?ListContourPlot3D blank box?Does anyone know a way to draw lines connecting nearest neighbor points in ListPlot[ ]?PlotRange->Automatic the exact function used to calculate outliersI need help on plotting surface through my list of data pointsHow do I make ListPlot join the points in order?ListContourPlot not plotting all data pointsMathematica returns a blank coordinate system when I try to plot dataMore resolution on ListContourPlot?










3












$begingroup$


I have found some software that allows me to "data mine" the values from publication figures. I have a bunch of contours from papers that I've mined using this software, and am having some trouble plotting the points with the Joined command.



Unfortunately, the downloaded points are sorted by increasing x values, which makes the plotting of Gaussian-esque contours very difficult. I've searched around the forums and haven't found anyone mentioning this problem.



Here's an example on a very small, simpler distribution (note my other sets are much larger so brute force definitely won't work.)



data=62.0774, 0.598737, 62.2377, 0.619119, 62.4048, 
0.580509, 62.5466, 0.637818, 62.9276, 0.654518, 62.9668,
0.566973, 63.3095, 0.671261, 63.8137, 0.688518, 63.8913,
0.565805, 64.4067, 0.703821, 64.8157, 0.568541, 65.1005,
0.718671, 65.7401, 0.573603, 65.9282, 0.732056, 66.6646,
0.580678, 66.7973, 0.743456, 67.6058, 0.589303, 67.7571,
0.755602, 68.5512, 0.599853, 68.6815, 0.761419, 69.4,
0.614478, 69.6059, 0.76384, 70.1679, 0.631668, 70.5117,
0.759937, 70.5514, 0.759266, 70.7216, 0.649606, 71.3609,
0.666955, 71.3764, 0.751005, 71.7909, 0.736308, 71.8078,
0.687055, 71.947, 0.702022, 72.0491, 0.717738

ListPlot[data]


points
gives me this:



While



ListLinePlot[data]


of course gives me this, because the points are ordered with increasing x-value:
lines



So, is there any way to either join the points by nearest neighbor, or re-order the list such that the joined command will give me a neat line? This seems like a traveling-salesman type problem, which could quickly get slow as I increase the number of points too much.










share|improve this question









$endgroup$







  • 1




    $begingroup$
    Try FindShortestTour
    $endgroup$
    – C. E.
    3 hours ago






  • 1




    $begingroup$
    Try something like ListLinePlot[data[[Last@FindShortestTour@data]]] but it is not perfect
    $endgroup$
    – J42161217
    2 hours ago















3












$begingroup$


I have found some software that allows me to "data mine" the values from publication figures. I have a bunch of contours from papers that I've mined using this software, and am having some trouble plotting the points with the Joined command.



Unfortunately, the downloaded points are sorted by increasing x values, which makes the plotting of Gaussian-esque contours very difficult. I've searched around the forums and haven't found anyone mentioning this problem.



Here's an example on a very small, simpler distribution (note my other sets are much larger so brute force definitely won't work.)



data=62.0774, 0.598737, 62.2377, 0.619119, 62.4048, 
0.580509, 62.5466, 0.637818, 62.9276, 0.654518, 62.9668,
0.566973, 63.3095, 0.671261, 63.8137, 0.688518, 63.8913,
0.565805, 64.4067, 0.703821, 64.8157, 0.568541, 65.1005,
0.718671, 65.7401, 0.573603, 65.9282, 0.732056, 66.6646,
0.580678, 66.7973, 0.743456, 67.6058, 0.589303, 67.7571,
0.755602, 68.5512, 0.599853, 68.6815, 0.761419, 69.4,
0.614478, 69.6059, 0.76384, 70.1679, 0.631668, 70.5117,
0.759937, 70.5514, 0.759266, 70.7216, 0.649606, 71.3609,
0.666955, 71.3764, 0.751005, 71.7909, 0.736308, 71.8078,
0.687055, 71.947, 0.702022, 72.0491, 0.717738

ListPlot[data]


points
gives me this:



While



ListLinePlot[data]


of course gives me this, because the points are ordered with increasing x-value:
lines



So, is there any way to either join the points by nearest neighbor, or re-order the list such that the joined command will give me a neat line? This seems like a traveling-salesman type problem, which could quickly get slow as I increase the number of points too much.










share|improve this question









$endgroup$







  • 1




    $begingroup$
    Try FindShortestTour
    $endgroup$
    – C. E.
    3 hours ago






  • 1




    $begingroup$
    Try something like ListLinePlot[data[[Last@FindShortestTour@data]]] but it is not perfect
    $endgroup$
    – J42161217
    2 hours ago













3












3








3


1



$begingroup$


I have found some software that allows me to "data mine" the values from publication figures. I have a bunch of contours from papers that I've mined using this software, and am having some trouble plotting the points with the Joined command.



Unfortunately, the downloaded points are sorted by increasing x values, which makes the plotting of Gaussian-esque contours very difficult. I've searched around the forums and haven't found anyone mentioning this problem.



Here's an example on a very small, simpler distribution (note my other sets are much larger so brute force definitely won't work.)



data=62.0774, 0.598737, 62.2377, 0.619119, 62.4048, 
0.580509, 62.5466, 0.637818, 62.9276, 0.654518, 62.9668,
0.566973, 63.3095, 0.671261, 63.8137, 0.688518, 63.8913,
0.565805, 64.4067, 0.703821, 64.8157, 0.568541, 65.1005,
0.718671, 65.7401, 0.573603, 65.9282, 0.732056, 66.6646,
0.580678, 66.7973, 0.743456, 67.6058, 0.589303, 67.7571,
0.755602, 68.5512, 0.599853, 68.6815, 0.761419, 69.4,
0.614478, 69.6059, 0.76384, 70.1679, 0.631668, 70.5117,
0.759937, 70.5514, 0.759266, 70.7216, 0.649606, 71.3609,
0.666955, 71.3764, 0.751005, 71.7909, 0.736308, 71.8078,
0.687055, 71.947, 0.702022, 72.0491, 0.717738

ListPlot[data]


points
gives me this:



While



ListLinePlot[data]


of course gives me this, because the points are ordered with increasing x-value:
lines



So, is there any way to either join the points by nearest neighbor, or re-order the list such that the joined command will give me a neat line? This seems like a traveling-salesman type problem, which could quickly get slow as I increase the number of points too much.










share|improve this question









$endgroup$




I have found some software that allows me to "data mine" the values from publication figures. I have a bunch of contours from papers that I've mined using this software, and am having some trouble plotting the points with the Joined command.



Unfortunately, the downloaded points are sorted by increasing x values, which makes the plotting of Gaussian-esque contours very difficult. I've searched around the forums and haven't found anyone mentioning this problem.



Here's an example on a very small, simpler distribution (note my other sets are much larger so brute force definitely won't work.)



data=62.0774, 0.598737, 62.2377, 0.619119, 62.4048, 
0.580509, 62.5466, 0.637818, 62.9276, 0.654518, 62.9668,
0.566973, 63.3095, 0.671261, 63.8137, 0.688518, 63.8913,
0.565805, 64.4067, 0.703821, 64.8157, 0.568541, 65.1005,
0.718671, 65.7401, 0.573603, 65.9282, 0.732056, 66.6646,
0.580678, 66.7973, 0.743456, 67.6058, 0.589303, 67.7571,
0.755602, 68.5512, 0.599853, 68.6815, 0.761419, 69.4,
0.614478, 69.6059, 0.76384, 70.1679, 0.631668, 70.5117,
0.759937, 70.5514, 0.759266, 70.7216, 0.649606, 71.3609,
0.666955, 71.3764, 0.751005, 71.7909, 0.736308, 71.8078,
0.687055, 71.947, 0.702022, 72.0491, 0.717738

ListPlot[data]


points
gives me this:



While



ListLinePlot[data]


of course gives me this, because the points are ordered with increasing x-value:
lines



So, is there any way to either join the points by nearest neighbor, or re-order the list such that the joined command will give me a neat line? This seems like a traveling-salesman type problem, which could quickly get slow as I increase the number of points too much.







plotting order






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 3 hours ago









zackzack

716




716







  • 1




    $begingroup$
    Try FindShortestTour
    $endgroup$
    – C. E.
    3 hours ago






  • 1




    $begingroup$
    Try something like ListLinePlot[data[[Last@FindShortestTour@data]]] but it is not perfect
    $endgroup$
    – J42161217
    2 hours ago












  • 1




    $begingroup$
    Try FindShortestTour
    $endgroup$
    – C. E.
    3 hours ago






  • 1




    $begingroup$
    Try something like ListLinePlot[data[[Last@FindShortestTour@data]]] but it is not perfect
    $endgroup$
    – J42161217
    2 hours ago







1




1




$begingroup$
Try FindShortestTour
$endgroup$
– C. E.
3 hours ago




$begingroup$
Try FindShortestTour
$endgroup$
– C. E.
3 hours ago




1




1




$begingroup$
Try something like ListLinePlot[data[[Last@FindShortestTour@data]]] but it is not perfect
$endgroup$
– J42161217
2 hours ago




$begingroup$
Try something like ListLinePlot[data[[Last@FindShortestTour@data]]] but it is not perfect
$endgroup$
– J42161217
2 hours ago










1 Answer
1






active

oldest

votes


















3












$begingroup$

You can use FindCurvePath to reorder your data. However, FindCurvePath expects the scale of the two coordinates to be close, so you need to rescale first:



new = FindCurvePath[data . 1, 0, 0, 100];
ListLinePlot[data[[#]]& /@ new]


enter image description here






share|improve this answer









$endgroup$












  • $begingroup$
    Why not just the closely related ListCurvePathPlot?
    $endgroup$
    – Roman
    1 hour ago










  • $begingroup$
    @Roman Did you try using ListCurvePathPlot? Because the data has such a small variation in the y coordinate, ListCurvePathPlot doesn't work well. That's why I scaled the data and used FindCurvePath to reorder the data, and then plotted the reordered data.
    $endgroup$
    – Carl Woll
    46 mins ago











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195229%2flistplot-join-points-by-nearest-neighbor-rather-than-order%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3












$begingroup$

You can use FindCurvePath to reorder your data. However, FindCurvePath expects the scale of the two coordinates to be close, so you need to rescale first:



new = FindCurvePath[data . 1, 0, 0, 100];
ListLinePlot[data[[#]]& /@ new]


enter image description here






share|improve this answer









$endgroup$












  • $begingroup$
    Why not just the closely related ListCurvePathPlot?
    $endgroup$
    – Roman
    1 hour ago










  • $begingroup$
    @Roman Did you try using ListCurvePathPlot? Because the data has such a small variation in the y coordinate, ListCurvePathPlot doesn't work well. That's why I scaled the data and used FindCurvePath to reorder the data, and then plotted the reordered data.
    $endgroup$
    – Carl Woll
    46 mins ago















3












$begingroup$

You can use FindCurvePath to reorder your data. However, FindCurvePath expects the scale of the two coordinates to be close, so you need to rescale first:



new = FindCurvePath[data . 1, 0, 0, 100];
ListLinePlot[data[[#]]& /@ new]


enter image description here






share|improve this answer









$endgroup$












  • $begingroup$
    Why not just the closely related ListCurvePathPlot?
    $endgroup$
    – Roman
    1 hour ago










  • $begingroup$
    @Roman Did you try using ListCurvePathPlot? Because the data has such a small variation in the y coordinate, ListCurvePathPlot doesn't work well. That's why I scaled the data and used FindCurvePath to reorder the data, and then plotted the reordered data.
    $endgroup$
    – Carl Woll
    46 mins ago













3












3








3





$begingroup$

You can use FindCurvePath to reorder your data. However, FindCurvePath expects the scale of the two coordinates to be close, so you need to rescale first:



new = FindCurvePath[data . 1, 0, 0, 100];
ListLinePlot[data[[#]]& /@ new]


enter image description here






share|improve this answer









$endgroup$



You can use FindCurvePath to reorder your data. However, FindCurvePath expects the scale of the two coordinates to be close, so you need to rescale first:



new = FindCurvePath[data . 1, 0, 0, 100];
ListLinePlot[data[[#]]& /@ new]


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 1 hour ago









Carl WollCarl Woll

74.1k398193




74.1k398193











  • $begingroup$
    Why not just the closely related ListCurvePathPlot?
    $endgroup$
    – Roman
    1 hour ago










  • $begingroup$
    @Roman Did you try using ListCurvePathPlot? Because the data has such a small variation in the y coordinate, ListCurvePathPlot doesn't work well. That's why I scaled the data and used FindCurvePath to reorder the data, and then plotted the reordered data.
    $endgroup$
    – Carl Woll
    46 mins ago
















  • $begingroup$
    Why not just the closely related ListCurvePathPlot?
    $endgroup$
    – Roman
    1 hour ago










  • $begingroup$
    @Roman Did you try using ListCurvePathPlot? Because the data has such a small variation in the y coordinate, ListCurvePathPlot doesn't work well. That's why I scaled the data and used FindCurvePath to reorder the data, and then plotted the reordered data.
    $endgroup$
    – Carl Woll
    46 mins ago















$begingroup$
Why not just the closely related ListCurvePathPlot?
$endgroup$
– Roman
1 hour ago




$begingroup$
Why not just the closely related ListCurvePathPlot?
$endgroup$
– Roman
1 hour ago












$begingroup$
@Roman Did you try using ListCurvePathPlot? Because the data has such a small variation in the y coordinate, ListCurvePathPlot doesn't work well. That's why I scaled the data and used FindCurvePath to reorder the data, and then plotted the reordered data.
$endgroup$
– Carl Woll
46 mins ago




$begingroup$
@Roman Did you try using ListCurvePathPlot? Because the data has such a small variation in the y coordinate, ListCurvePathPlot doesn't work well. That's why I scaled the data and used FindCurvePath to reorder the data, and then plotted the reordered data.
$endgroup$
– Carl Woll
46 mins ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195229%2flistplot-join-points-by-nearest-neighbor-rather-than-order%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bett Inhaltsverzeichnis Geschichte | Bettformen | Bettgrößen | Andere Bezeichnungen | Bettenmangel | Betten in der bildenden Kunst | Schlafmedizinische Gesichtspunkte | Siehe auch | Literatur | Weblinks | Einzelnachweise | NavigationsmenüBett, Bettstatt, BettstelleCommons: BettBabybetten: Anwendung, Ausstattungsmerkmale und VergleichskriterienWasserbetten. Vorurteile im TestHapfnNursch10.1007/s11818-012-0584-74006250-8AKS4329276-8

Luksemburg Sisukord Nimi | Asend | Loodus | Riigikord | Haldusjaotus | Rahvastik | Riigikaitse | Majandus | Taristu | Ajalugu | Eesti ja Luksemburgi suhted | Haridus | Kultuur | Vaata ka | Viited | Välislingid | Navigeerimismenüü50° N, 6° EÜlevaade Luksemburgi kaitsealadest.Luksemburgi rahvaarv. Statistikaamet.World Bank'i andmebaasÜlevaade Luksemburgi loodusest.Ülevaade Luksemburgi metsadest.Guy Colling. "Red List of the Vascular Plants of Luxembourg." Travaux scientifiques du Musée national d’histoire naturelle Luxembourg. 2005.Luxembourg’s biodiversity at risk.Maailma kahepaiksete andmebaas.Denis Lepage. "Luxembourg." Avibase.Ülevaade temperatuuridest. Luksemburgi meteoroloogiateenistus.Ülevaade Luksemburgist. Euroopa Liidu esinduse koduleht.Système politique. TerritoireÜlevaade Luksemburgi rahvastikust. Luksemburgi statistikaamet.Luksemburgi rahvastik. Luksemburgi statistikaamet.The World FactbookMonique Borsenberger, Paul Dickes. "Religions au Luxembourg. Quelle évolution entre 1999-2008". Luksemburgi statistikaamet. 2011.Luksemburgi peapiiskopkond. Catholic-Hierarchy.Luksemburgi armee koduleht.Luksemburgi armee relvastus.Eesti Välisministeerium.Luksemburgi rahvastik. Luksemburgi statistikaamet.Luksemburgi Eesti Seltsi koduleht.Helen Eelrand. "Raadio, mis muutis maailma." Eesti Päevaleht. 13. märts 2004.Ülevaade Luksemburgi haridussüsteemist.Ülevaade Luksemburgi keskkoolidest.Luksemburgr

Valle di Casies Indice Geografia fisica | Origini del nome | Storia | Società | Amministrazione | Sport | Note | Bibliografia | Voci correlate | Altri progetti | Collegamenti esterni | Menu di navigazione46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)Sito istituzionaleAstat Censimento della popolazione 2011 - Determinazione della consistenza dei tre gruppi linguistici della Provincia Autonoma di Bolzano-Alto Adige - giugno 2012Numeri e fattiValle di CasiesDato IstatTabella dei gradi/giorno dei Comuni italiani raggruppati per Regione e Provincia26 agosto 1993, n. 412Heraldry of the World: GsiesStatistiche I.StatValCasies.comWikimedia CommonsWikimedia CommonsValle di CasiesSito ufficialeValle di CasiesMM14870458910042978-6