# Superimposing ListContourPlots on each other

I have two ListContorPlots that I would like to plot on top of each other for easy visualization. I tried using Overlay for that, but the result was not good at all, as I couldn't distinguish the two plots from each other:

a = ListContourPlot[RandomReal[1, {10, 10}], InterpolationOrder -> 3,
PlotLegends -> Automatic];
b = ListContourPlot[
Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]];
Overlay[{a, b}]


Then I tried with

ListContourPlot[{Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}],
RandomReal[1, {10, 10}]}]


which is somewhat better -- however, it would be nice if I could give the plots different color codings to easier distinguish them.

Is there another way to do this?

• Show[{b, a}] for your first case, perhaps adding color/colorfunction/transparency options to each plot?
– ciao
Sep 4 '15 at 9:15
• Your plots have different axes ranges from what I can see, how would you like to deal with that ? Sep 4 '15 at 9:43
• Displaying two contour plots in the same graphics panel is like placing one rug on top of another -- the upper one hides the lower one. Sep 4 '15 at 11:36
• @m_goldberg that was also what I was thinking.. I hoped there would be a nice work-around though. thanks Sep 4 '15 at 11:37
• So many great suggestion, thanks to all. WIsh I could accept more than one solution Sep 7 '15 at 8:05

So like image_doctor pointed out, you need to have your plots have the same range to overlay them. Then there is the fact that you are laying one carpet on top of the other, like m_goldberg pointed out.

But there are ways to deal with this. First, some data

data1 = Table[(x - 1)^2 + (y - 1)^2, {x, -4, 4, .1}, {y, -4, 4, .1}];
data2 = Table[3 (x + 1)^2 + (y + 1)^2, {x, -4, 4, .1}, {y, -4, 4, .1}];


When you plot them with ListContourPlot, be sure and give them both the same DataRange

plot1 = ListContourPlot[data1, DataRange -> {{-4, 4}, {-4, 4}}];
plot2 = ListContourPlot[data2, DataRange -> {{-4, 4}, {-4, 4}}];
Show[plot1, plot2] But that looks awful, one is completely covering the other one. Personally, I don't like for my contour plots to have color shading - I'm old fashioned, I like a white background. That works great with this:

plot1 = ListContourPlot[data1, DataRange -> {{-4, 4}, {-4, 4}},
ContourShading -> False, ContourStyle -> Blue];
plot2 = ListContourPlot[data2, DataRange -> {{-4, 4}, {-4, 4}},
ContourShading -> False, ContourStyle -> Red];
Show[plot1, plot2] But if you are dead set on using the color shading, then make one of them transparent:

plot1 = ListContourPlot[data1, DataRange -> {{-4, 4}, {-4, 4}}];
plot2 = ListContourPlot[data2, DataRange -> {{-4, 4}, {-4, 4}},
ColorFunction ->
Function[f, Opacity[.5, ColorData["BlueGreenYellow"][f]]]];
Show[plot1, plot2] Edit: You can obviously also do this with your example data, which simply came from the Help page on ListContourPlot

a = ListContourPlot[RandomReal[1, {10, 10}], InterpolationOrder -> 3,
PlotLegends -> Automatic, DataRange -> {{1, 30}, {1, 30}},
ContourShading -> False, ContourStyle -> Dashed];
b = ListContourPlot[
Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}],
PlotLegends -> Automatic];
Show[b, a] • I very much like that all these methods preserve the interactivity of the plots and are achieved through standard options and settings of ListContourPlot. +1 Sep 4 '15 at 13:42

If you really want to do this you can use Show and replace the colors in the graphic with the colors and an opacity value.

RGBColor[1, 0, 0] /. RGBColor[R_, B_, G_] -> RGBColor[R, B, G, 0.5]
// FullForm

RGBColor[1,0,0,0.5]


Applying to your plots a and b use

Show[
a,
b /. RGBColor[R_, B_, G_] -> RGBColor[R, B, G, 0.5]
]


This gives b on top of a. Note that the x-y scale is determined from the plot a.

You can use different color schemes (see ColorData) if you don't want the same colors. You can also have complete control using ColorFunction.

Not sure if this is what you want. Anyway:

a = ListContourPlot[RandomReal[1, {10, 10}], InterpolationOrder -> 3];
b = ListContourPlot[ Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}],
ColorFunction -> "Rainbow"];
ImageCompose[a , {b, .5}] This is the best idea I have been able to come up with for visualizing the data you describe in your question.

SeedRandom;
a =
Interpolation[
Flatten[Table[{x, y, RandomReal[]}, {x, 0, 3, .25}, {y, 0, 3, .25}], 1]]; 1]];
Quiet @
Plot3D[{a[x, y], Sin[x + y^2]}, {x, 0, 3}, {y, 0, 3},
PlotRange -> 1,
ClippingStyle -> None] 