# Joining data from different lists

Let's create some sample data

Clear["Global*"];

data1 = {{1, 0.2}, {3, 1.2}, {5, -0.4}};
data2 = {{2, -0.9}, {4, -0.1}, {6, 0.3}};

L1 = ListPlot[data1, PlotStyle -> {Blue, PointSize[0.012]}];
L2 = ListPlot[data2, PlotStyle -> {Red, PointSize[0.012]}];

plot = Show[{L1, L2}, PlotRange -> All]


My question is the following: how can I connect with straight lines (in black color) all the data (from both lists), starting from that with the lowest value of $x$, up to the one with the largest value of $x$ coordinate?

Any suggestions?

data3  = SortBy[Join[data1, data2], First];

Show[ListPlot[data3, Joined -> True, PlotStyle -> Black], L1, L2]


or

ListPlot[data3, Joined -> True, PlotStyle -> Black,  Epilog -> {L1[[1]], L2[[1]]}]


or

ListPlot[{data1, data2, data3}, Joined -> {False, False, True},
PlotStyle -> {Directive[Blue, PointSize[0.012]],
Directive[Red, PointSize[0.012]], Directive[Black, PointSize[0]]}]


all give

Alternatively, using Mesh:

ListPlot[data3, Joined -> True, PlotStyle -> Black, BaseStyle -> PointSize[Large],


• II want the points to have the original color (red and blue); not all of them with the same color. Commented Jan 2, 2018 at 20:32
ListLinePlot[SortBy[Join[data1, data2], First], PlotStyle -> Black]


Update:

data = SortBy[Join[data1, data2], First];
ListLinePlot[data, PlotStyle -> Black,
Epilog -> {PointSize[Large], {Blue, Point[data1]}, {Red, Point[data2]}}]


• Nice! But if I want also the points on the same diagram? Commented Jan 2, 2018 at 20:14
• II want the points to have the original color (red and blue); not all of them with the same color. Commented Jan 2, 2018 at 20:27

You may do the following as well:

 ss = Riffle[data1, data2]

ListLinePlot[ss,Mesh -> Full]
`
• But if I want also the points on the same diagram? Commented Jan 2, 2018 at 20:22
• Just add the option Mesh->Full Commented Jan 2, 2018 at 20:25
• II want the points to have the original color (red and blue); not all of them with the same color. Commented Jan 2, 2018 at 20:27