# Is it possible to exclude a condition, say, $f(x,y)=const.$, from a ContourPlot code?

p1 = RegionPlot[   -(3/4) <= Sin[x y] <= 1/2 , {x, 0, 3}, {y, 0, 4},
FrameLabel -> Automatic, PlotStyle -> LightBlue];

p2=Manipulate[  Show[p1, ContourPlot[Sin[x y] + z == 1  , {x, 0, 3}, {y, 0, 4},
FrameLabel -> Automatic, ContourStyle -> Black]], {z, 0, 1}]


and I get

Question:

Is it possible to exclude those $$(x,y)$$ which satisfy a general condition, say, $$f(x,y)=const.$$ from $$p2$$? In general, how we can exclude a condition (again, say, $$f(x,y)=const.$$) from the ContourPlot? for example, in the following simple code

ContourPlot[ Sin[x y]== 1/2 , {x, 0, 3}, {y, 0, 4}]

• What is the f[x,y]? Commented Jan 31, 2022 at 2:33
• @cvgmt It can be any two-variable function, say $\sin xy=\frac34$ ; I just want to know how to exclude a condition for the ContourPlot. Commented Jan 31, 2022 at 2:42

Excluded parts of a ContourPlot are White so set the style of the contour to be excluded to White

p1 = RegionPlot[-(3/4) <= Sin[x y] <= 1/2,
{x, 0, 3}, {y, 0, 4},
FrameLabel -> Automatic,
PlotStyle -> LightBlue];

p2 = Manipulate[
Show[p1,
ContourPlot[
{Sin[x y] + z == 1, Sin[x y] == 1/2},
{x, 0, 3}, {y, 0, 4},
ContourStyle -> {Black,
Switch[state,
exclude, White,
normal, Lighter[Blue, 0.5],
highlight, Red]}]],
{{state, normal, "specified contour"}, {normal, highlight, exclude},
{{z, 0.2}, 0, 1, 0.01, Appearance -> "Labeled"}]


Exclusions work for some functions.

Here we exclude y-2x==0

ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 4},
Exclusions -> {y - 2 x == 0}, ContourStyle -> None,
Contours -> {-3/4, 1/2}, ContourShading -> {None, Blue, None}]

ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 4},
RegionFunction -> Function[{x, y}, -3/4 <= Sin[x*y] <= 1/2],
Exclusions -> {y - 2 x == 0},
ColorFunction -> (Blend[{Blue, Blue}, #] &), ContourStyle -> None]

DensityPlot[Sin[x y], {x, 0, 3}, {y, 0, 4},
RegionFunction -> Function[{x, y}, -3/4 <= Sin[x*y] <= 1/2],
Exclusions -> {y - 2 x == 0},
ColorFunction -> (Blend[{Blue, Blue}, #] &)]


Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 4},
RegionFunction -> Function[{x, y}, -3/4 <= Sin[x*y] <= 1/2],
Mesh -> None, PlotStyle -> Darker@Cyan,
Lighting -> {{"Ambient", White}}, ViewPoint -> Top,
ViewProjection -> "Orthographic", Exclusions -> {y - x == 0},
Axes -> {True, True, False}]