How to join points {x1,y1} and {x2,y2} only if x2-x1==1

Given

list={{5, 3}, {9, 5}, {10, 4}, {11, 3}, {13, 3}, {14, 4}}


I want to ListPlot these points and use Joined only for those points where the x-values differ by one. So here I would get two line segments {{9, 5}, {10, 4}, {11, 3}} and  {{13, 3}, {14, 4}} . I tried to add conditions to Joined but could not get anywhere. I also want to Plot the single points left over. Any ideas?

You can also use RelationGraph as follows:

RelationGraph[#2[[1]] == #[[1]] + 1 &, list, VertexCoordinates -> list]


rg = RelationGraph[#2[[1]] == #[[1]] + 1 &, list,
VertexCoordinates -> list,
EdgeStyle -> Directive[CapForm["Round"], Opacity[.5], AbsoluteThickness[15]],
EdgeShapeFunction -> "Line"]


We can get the pieces using WeaklyConnectedComponents and style the edges and vertices using VertexShapeFunction and HighlightGraph:

wcc = WeaklyConnectedComponents[rg];

SeedRandom[12]
vshapes = Thread[Alternatives @@@ wcc ->
RandomSample[GraphElementData["VertexShapeFunction"], Length @ wcc]];

HighlightGraph[SetProperty[rg, {VertexSize -> .1, VertexShapeFunction -> vshapes}],
Subgraph[rg, #] & /@ wcc, GraphHighlightStyle -> "Thick"]


list = {{5, 3}, {9, 5}, {10, 4}, {11, 3}, {13, 3}, {14, 4}};

list2 = Split[list, #2[[1]] - #1[[1]] == 1 &];

ListPlot[list2, Joined -> True]


or with PlotMarkers

ListPlot[list2, Joined -> True, PlotMarkers -> Automatic]


• Great! Thanks! But I forgot to mention that I want to plot the single points, too. Commented Mar 5, 2021 at 13:38
• @user57467 Please add that requirement to the question! Commented Mar 5, 2021 at 13:42
• "I want to ListPlot these points" seems clear enough to me. Commented Mar 5, 2021 at 21:50

Or use FindClusters

FindClusters[{{5, 3}, {9, 5}, {10, 4}, {11, 3}, {13, 3}, {14, 4}}, 3,
DistanceFunction -> (Abs[#1 - #2][[1]] &)]


{{{5, 3}}, {{9, 5}, {10, 4}, {11, 3}}, {{13, 3}, {14, 4}}}