# Plotting different parts of different lists of data

Suppose I have the following data:

x = Range;
y1 = N[RandomInteger[100, 15]/100];
y2 =  N[RandomInteger[100, 15]/100];
y3 =  N[RandomInteger[100, 15]/100];


Now, I wish to plot values 1 to 5 of x against values 1 to 5 of y1, values 6 to 10 of x against 6 to 10 of y2, and values 11 to 15 of x against 11 to 15 of y3. Moreover, I wish to show the plots on the same chart, showing the entire range of x.

How is that done? Note that the range of 5 data points at a time was just an example. The ranges in my actual problem are varied, but never overlapping.

## 3 Answers

x = Range;
y1 = N[RandomInteger[100, 15]/100];
y2 = N[RandomInteger[100, 15]/100];
y3 = N[RandomInteger[100, 15]/100];

ListLinePlot[{
Transpose[{x, y1}][[1 ;; 5]],
Transpose[{x, y2}][[6 ;; 10]],
Transpose[{x, y3}][[11 ;; 15]]
}] Would something like this work for you?

x = Range;
y1 = N[RandomInteger[100, 15]/100];
y2 = N[RandomInteger[100, 15]/100];
y3 = N[RandomInteger[100, 15]/100];
cutoffs = {1, 5, 6, 10, 11, 15};
ListLinePlot[
Table[
{x, y1, y2, y3}\[Transpose][[cutoffs[[2 i - 1]] ;; cutoffs[[2 i]], {1, i + 1}]],
{i, 3}
]
] You can also use TemporalData as follows:

intervals = {{1, 5}, {6, 10}, {11, 15}};
td = TemporalData[{y1, y2, y3}, {x}];
parts = MapIndexed[td["Part", #2[], #] &, intervals];
ListLinePlot[parts, GridLines -> {Flatten @ intervals, None}, Filling -> Bottom] intervals2 = {{1, 6}, {3, 12}, {7, 15}};
ListLinePlot[MapIndexed[td["Part", #2[], #] &, intervals2],
Filling -> {1 -> Bottom , 2 -> 1, 3 -> Bottom},
GridLines -> {Flatten @ intervals2, None}] 