Plotting a pairwise difference interval of more than two vectors

If I have a 6 vectors:

v1 = {-2, -15, -4, -12, -8, -6, -14, -32}
v2 = {5, 12, 3, 5, 9, 32, 12, 8}
v3 = {4, 11, 46, 14, 22, 20, 7, 23}
v4 = {27, 9,30, 35, 36, 12, 39, 5}
v5 = {15, 10, 3, 9, 6, 30, 12, 7}
v6 = {2, 19,30, 3, 36, 12, 7, 13}

I want to Plot a pairwise difference intervals (as a line) of v1 – v2, v3 – v4, v5 – v6, in one plot with different colors. I know for the two vectors from previous question. But I can’t do it
for more vectors. Thank you for help.

=================

  

 

Please post code in a copyable format, so people can use it immediately without retyping. LaTeX looks good, but it is not copyable.
– Szabolcs
Jun 23 at 8:17

  

 

ListPlot[Substract@@@Partition[allV, 2]] will probably work if you have all your vectors in allV (untested).
– Szabolcs
Jun 23 at 8:18

=================

2 Answers
2

=================

NumberLinePlot[
Interval /@ Join[
Transpose[{v1, v2}],
Transpose[{v3, v4}],
Transpose[{v5, v6}]]]

Wrap Join with SortBy, like SortBy[Join[…], First] for example, to sort the intervals by starting value.

You can program the joining part, if you have a large number n of vectors defined as v[1], v[2] … v[n]:

NumberLinePlot[
Interval /@ Join @@ Table[
Transpose[{v[i], v[i + 1]}], {i, 1, n, 2}]]

Description

I am not quiet sure if I am getting the right idea what you are after. So, please see interpretation below.

Example

Code

Module[{
v1 = {-2, -15, -4, -12, -8, -6, -14, -32},
v2 = {5, 12, 3, 5, 9, 32, 12, 8},
v3 = {4, 11, 46, 14, 22, 20, 7, 23},
v4 = {27, 9, 30, 35, 36, 12, 39, 5},
v5 = {15, 10, 3, 9, 6, 30, 12, 7},
v6 = {2, 19, 30, 3, 36, 12, 7, 13},
r1, r2, r3
},
r1 = v1 – v2;
r2 = v3 – v4;
r3 = v5 – v6;

NumberLinePlot[ (Interval @ {Min @ #, Max @ #} & @ Sort @ # & /@ {r1,
r2, r3}), PlotLegends -> “Expressions”]
]

Output

Reference

Min
Max
Sort
Interval
NumberLinePlot