# Plotting multiple contour plots

Suppose, I have a table with five columns where first four columns represent some variable parameters and fifth column represents value of function at those parameters. I want to have a contour plot for every possible combination of these four parameters. For example- First Using first and second column then first and third and so on. One way to do this is to plot every possible combination of these parameters and write ListContourPlot command for every combination. Is there any minimal way to plot contours for every possible combination? I have tried-

For[i = 1, i <= 10, i++,
d1 = RandomReal[{100, 1000}];
d2 = RandomReal[{100, 1000}];
d3 = RandomReal[{100, 1000}];
d4 = RandomReal[{100, 1000}];
d5 = d1 + d2 + d3 + d4 ;
list[i] = {d1, d2, d3, d4, d5};
]
list1 = Table[list[i], {i, 1, 10}];
list2 = list1[[All, {1, 2, 5}]];
list3 = list1[[All, {1, 3, 5}]];
list4 = list1[[All, {1, 4, 5}]];
ListContourPlot[list2]
ListContourPlot[list3]
ListContourPlot[list4]

• Can you present a minimal example? What have you tried? – Mauricio Fernández Apr 6 '17 at 13:31
• @MauricioLobos I have edited the question. – solphy101 Apr 6 '17 at 13:46
• Try this: Table[ListContourPlot[list[[All, Append[xy, 5]]]], {xy, Subsets[Range, {2}]}] – J. M.'s torpor Apr 6 '17 at 13:54
• @J.M. How can I give specific frame labels for each plot? – solphy101 Apr 6 '17 at 14:32
• Look up PlotLabel. – J. M.'s torpor Apr 6 '17 at 14:39

## 2 Answers

Here is how to get all possible pairs of contour plots.

First, generate data (avoiding the notorious For function):

n = 100;  (* Number of samples *)
k = 4; (* Number of predictor variables *)
(* Generate data *)
data = RandomReal[{100, 1000}, {n, k + 1}];
(* (k+1)-th variable as a function of the first k variables *)
data[[All, k + 1]] = Sum[data[[All, i]], {i, k}];


Now produce all possible pairwise plots:

pairs = Select[Tuples[Range[1, k], 2], #[] < #[] &];
Table[ListContourPlot[data[[All, Flatten[{pairs[[i]], k + 1}]]]], {i, Length[pairs]}] • Consider using Subsets[] instead of Tuples[]. – J. M.'s torpor Apr 6 '17 at 15:03
• Thanks @J.M. (This is one of the reasons I attempt to answer these questions. You folks help me (and everybody else) learn to be more efficient and expose us to the zillions of commands I don't know.) – JimB Apr 6 '17 at 15:05
SeedRandom
For[i = 1, i <= 10, i++,
d1 = RandomReal[{100, 1000}];
d2 = RandomReal[{100, 1000}];
d3 = RandomReal[{100, 1000}];
d4 = RandomReal[{100, 1000}];
d5 = d1 + d2 + d3 + d4;
list[i] = {d1, d2, d3, d4, d5};]
list1 = Table[list[i], {i, 1, 10}];


Note that this can be coded more simply as

SeedRandom
list2 = Flatten[{#, Total[#]}] & /@
RandomReal[{100, 1000}, {10, 4}];


Verifying the equivalence,

list1 === list2

(*  True  *)


EDIT Added labels

labels = {"a", "b", "c", "d", "Total"};

(ListContourPlot[
list1[[All, {#[], #[], 5}]],
FrameLabel -> (Style[#, 14, Bold] & /@labels[[#]]),
PlotLabel -> Style["ContourPlot of " <> Last[labels], 14, Bold]] & /@
Subsets[Range, {2}]) //
Partition[#, 2] & //
Grid[#, Spacings -> {2, 2}] & • How can I give specific frame labels to each plot? – solphy101 Apr 6 '17 at 14:37
• Total no. of plots should be six? – solphy101 Apr 6 '17 at 15:52
• @solphy - I merely produced what was shown in your code. – Bob Hanlon Apr 6 '17 at 21:30
• Is it possible to label elements of the list and use those labels as FrameLabel for each individual plot? – solphy101 Apr 7 '17 at 5:50
• @solphy - spend some time formulating your questions so that they are completely described and do not need repeated modifications. – Bob Hanlon Apr 7 '17 at 6:21