I have the following functions, which are
x^2 - y^2
and
2 x y
of two variables which represent the real and imaginary part of a complex function $f(z)$. I want to show that the contour lines of the two function intersect perpendicularly. I have the two ContourPlot
cp1 = ContourPlot[x^2 - y^2, {x, -10, 10}, {y, -10, 10},
Contours -> 20,
PlotLegends -> Automatic, ColorFunction -> "Rainbow"];
cp2 = ContourPlot[2 x y, {x, -10, 10}, {y, -10, 10}, Contours -> 20,
PlotLegends -> Automatic, ColorFunction -> "Rainbow"];
What I would like to do is to overlap the two plots keeping the color between the contour lines, but with opacity so that I can see the contours below intersecting normally the contours above.
I partially achieved this result with:
cp1 = ContourPlot[x^2 - y^2, {x, -10, 10}, {y, -10, 10},
Contours -> 20,
PlotLegends -> Automatic, ColorFunction -> "Rainbow"];
cp2 = ContourPlot[2 x y, {x, -10, 10}, {y, -10, 10},
Mesh -> None,
(*ContourShading->None, *)
ColorFunction -> Function[f, Opacity[.5, ColorData["Rainbow"][f]]],
Contours -> 20,
PlotLegends -> Automatic
];
Show[cp1, cp2]
but as you can notice there's a strange grid below the fist plot...
EDIT (completness):
I'm using mathematica 11.1.0.0
Show[cp1, cp2 /. EdgeForm[] -> EdgeForm[Directive[Opacity[0]]]]
. Does it for you? $\endgroup$cp1
. (The same trick does not work on it.) $\endgroup$