# ListPlot two matrices on the same graph and shade the region between them

I have two lists of Dimension[list1] = {6,110} similarly for list2.

I would like to ListPlot[{list1, list2}] and then shade the region between the curve corresponding to the nth line of list1 and the curve corresponding to the nth line of list2, (without really using Show unless its the absolute final step).

The object temp ={list1,list2} has Dimension[temp] = {2,6,110} which cannot be ListPlotted straight away.

Any suggestions?

• does this give what you need: ListPlot[Join[list1, list2], Joined -> True, Filling -> Thread[Range[6] -> List /@ Range[7, 12]]]?
– kglr
Feb 1, 2018 at 16:49
• Holy cow this looks interesting, let me get back to you. Feb 1, 2018 at 16:52
• Is it possible to have the same color for the same curve? Your current code is beautiful but it gives two different colors for the curves that constitutes the boundary of the shaded region. Feb 1, 2018 at 17:14
• It would be nice if (1 and 7), (2 and 8),...(6 and 12) pairwise had the same color. Is this possible to implement? Feb 1, 2018 at 17:32
• Faq, I posted the comment as an answer with the styling feature added.
– kglr
Feb 1, 2018 at 17:33

list1 = Mean[3 # + RandomVariate[NormalDistribution[2, 1], {6, 110}]] & /@ Range[6];
list2 = list1 + 3 (StandardDeviation /@ list1);
temp = {list1, list2};
colors = ColorData[97, "ColorList"][[ ;; 6]];
filling = Thread[Range[6] -> List /@ Range[7, 12]];

ListLinePlot[Join @@ temp,  PlotStyle -> colors, Filling -> filling,
PlotLegends ->  SwatchLegend[colors, StringJoin["pair", #] & /@ (ToString /@ Range[6]),
LegendLayout -> {"ReversedColumn", 1}], ImageSize -> 500 ]


Update:

is there a way to say let curve 1 in the numeration of filling be dashed while curve 7 solid. Meanwhile curve 2 solid while curve 8 dashed and so on?

Instead of PlotStyle -> colors above use PlotStyle -> styles where

 styles = Join[Directive[#, Dashed]& /@ #, #]& @colors


to get

• 😳 Let me try this out a minute. Feb 1, 2018 at 17:33
• That's a beautiful solution! Feb 1, 2018 at 19:09
• @Faq, glad it was useful. Thank you for the accept.
– kglr
Feb 1, 2018 at 19:34
• One final follow up, is there a way to say let curve 1 in the numeration of filling be dashed while curve 7 solid. Meanwhile curve 2 solid while curve 8 dashed and so on? Feb 1, 2018 at 19:57
• Faq, please see the update.
– kglr
Feb 1, 2018 at 20:08