# ListLinePlot without joined the data point

I have some data points in given below format:

data = {{0, 0}, {0.5, 2}, {1, 5}, {2, 8.5}, {4, 10}, {0, 0}, {0.5,
4}, {1, 7}, {2, 9.5}, {4, 12}, {0, 0}, {0.5, 5}, {1, 9}, {2,
12}, {4, 18}};


How to plot these data in ListLinePlot without joining the line from last data point to first one (highlighted by yellow square)?

• What code generated the plot? – Coolwater Jan 14 '18 at 11:32
• ListLinePlot[data] – Gopal Verma Jan 14 '18 at 11:33
• That makes no sense. The maximal y-value in data is 10, whereas on the plot it's 19. – Coolwater Jan 14 '18 at 11:41
• Please post the full code that gave your output. With the given data, we can get this. – corey979 Jan 14 '18 at 12:07
• Shall data describe a single curve or 3? (In the latter case, the three curves would be equal.) – Henrik Schumacher Jan 14 '18 at 12:09

ListLinePlot[Split[data, #2 =!= {0, 0} &], PlotMarkers -> Automatic]


Edit

The problem with the 'real' data imported from drive.google.com/open?id=1uXuPcB-ibTS3Q7d4EDluyz-JF-wm_CLL is merely one of machine precision versus exact values for {0,0} - the y-values of each 'split point' are very close to but not exactly zero.

Mathematica has a very nice command, Chop, which 'replaces approximate real numbers in expr that are close to zero by the exact integer 0.", and one way of solving the problem is as follows:

ListLinePlot[Split[Chop[data, 0.0001], #2 =!= {0, 0} &], PlotMarkers -> Automatic]


Data were imported with:

data = Import["glv.1to.5.txt", "Data"];

• Thanks it working on data that is given here, but it is not working on .txt imported data file? – Gopal Verma Jan 14 '18 at 21:20
• @GopalVerma Can you supply a copy of the .txt file? (and, if possible, the code you use to import). – user1066 Jan 14 '18 at 23:26
• Pls. find the link of data file. I am using Import[filename.txt,"Data".] command for importing the data file. drive.google.com/open?id=1uXuPcB-ibTS3Q7d4EDluyz-JF-wm_CLL – Gopal Verma Jan 15 '18 at 16:52
• Thanks,It is working. – Gopal Verma Jan 15 '18 at 22:17
• Can u suggest how to change the thickness of line joining the data point(or plot markers). – Gopal Verma Jan 20 '18 at 16:08
data = {{0, 0}, {0.5, 2}, {1, 5}, {2, 8.5}, {4, 10}, {0, 0}, {0.5, 4}, {1, 7}, {2, 9.5}, {4, 12}, {0, 0}, {0.5, 5}, {1, 9}, {2, 12}, {4, 18}};


By splitting the data separate curves are obtained

ListLinePlot[TakeList[data,
Length /@ Split[Module[{i = 0, prev = -∞},
Table[If[prev < (prev = j), i, ++i], {j, data[[All, 1]]}]]]]]


Alternatively:

(* positions where new curve start *)
pos = Position[UnitStep[Differences[data[[All, 1]]]], 0][[All, 1]]

ListLinePlot[TakeList[data,
Append[Differences[Join[{0}, pos]], UpTo[∞]]]]

• I think you meant Take[List ... ]. – Themis Jan 14 '18 at 14:02
• @Themis No, TakeList is new in 11.2 – Coolwater Jan 14 '18 at 14:04
• Thanks, But I don't have Math. 11.2 so can u suggest any other option for that. – Gopal Verma Jan 14 '18 at 14:52
• @Coolwater Good to know, I am still in 11.1.1. – Themis Jan 14 '18 at 15:07
• @GopalVerma In older versions replace TakeList by InternalPartitionRagged – Coolwater Jan 14 '18 at 15:20

Does

ListLinePlot[Partition[data, Floor[Length[data]/3]]]


do what you seek for?

• Sorry,It is not working. – Gopal Verma Jan 14 '18 at 13:29
• Joining line (highlighted by yellow square: updated figure) still present in graph. – Gopal Verma Jan 14 '18 at 13:37
• @GopalVerma It does work. – corey979 Jan 14 '18 at 16:33

Another alternative is to insert a Null element where you want a break in the line:

data2 = {{0, 0}, {0.5, 2}, {1, 5}, {2, 8.5}, {4, 10}, Null,
{0, 0}, {0.5, 4}, {1, 7}, {2, 9.5}, {4, 12}, Null,
{0, 0}, {0.5, 5}, {1, 9}, {2, 12}, {4, 18}};
ListLinePlot[data2]


• (+1). Or alternatively: ListLinePlot[Riffle[data, Null, 6]]` – user1066 Jan 14 '18 at 19:28