# 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? Apr 6, 2017 at 13:31
• @MauricioLobos I have edited the question. Apr 6, 2017 at 13:46
• Try this: Table[ListContourPlot[list[[All, Append[xy, 5]]]], {xy, Subsets[Range[4], {2}]}] Apr 6, 2017 at 13:54
• @J.M. How can I give specific frame labels for each plot? Apr 6, 2017 at 14:32
• Look up PlotLabel. Apr 6, 2017 at 14:39

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], #[[1]] < #[[2]] &];
Table[ListContourPlot[data[[All, Flatten[{pairs[[i]], k + 1}]]]], {i, Length[pairs]}]


• Consider using Subsets[] instead of Tuples[]. Apr 6, 2017 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, 2017 at 15:05
SeedRandom[1]
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[1]
list2 = Flatten[{#, Total[#]}] & /@
RandomReal[{100, 1000}, {10, 4}];


Verifying the equivalence,

list1 === list2

(*  True  *)


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

(ListContourPlot[
list1[[All, {#[[1]], #[[2]], 5}]],
FrameLabel -> (Style[#, 14, Bold] & /@labels[[#]]),
PlotLabel -> Style["ContourPlot of " <> Last[labels], 14, Bold]] & /@
Subsets[Range[4], {2}]) //
Partition[#, 2] & //
Grid[#, Spacings -> {2, 2}] &


• How can I give specific frame labels to each plot? Apr 6, 2017 at 14:37
• Total no. of plots should be six? Apr 6, 2017 at 15:52
• @solphy - I merely produced what was shown in your code. Apr 6, 2017 at 21:30
• Is it possible to label elements of the list and use those labels as FrameLabel for each individual plot? Apr 7, 2017 at 5:50
• @solphy - spend some time formulating your questions so that they are completely described and do not need repeated modifications. Apr 7, 2017 at 6:21