# ContourPlot combined with Piecewise bug

I'm plotting a two dimensional von Mises and Tresca yield surface and got:

ContourPlot[{Sqrt[sr^2 - sr st + st^2] == 1, Abs[(sr - st)/2] == 1/2,
sr == 1, st == 1, sr == -1, st == -1}, {sr, -2, 2}, {st, -2, 2}] I need to cut the lines that are crossing the smooth surface. So I tried:

piece = Piecewise[{{st == 1, 0 <= sr <= 1}, {sr == 1,
0 <= st <= 1}, {st == 1, -1 <= sr <= 0}, {sr == 1, -1 <= st <= 0}}]
ContourPlot[{Sqrt[sr^2 - sr st + st^2] == 1, Abs[(sr - st)/2] == 1/2,
piece}, {sr, -2, 2}, {st, -2, 2}] What's the issue here?

• Perhaps its that the theory underlying ContourPlot assumes the function is continuous. – Michael E2 Sep 29 '17 at 1:10

maybe this is what you are after?

ContourPlot[{
Max[Abs[x - y], Abs[x], Abs[y]] == 1,
Sqrt[x^2 - x y + y^2] == 1
}, {x, -2, 2}, {y, -2, 2},
PlotPoints -> 100] The problem arises because Piecewise is evaluated sequentually. FullSimplify shows, you get False.

FullSimplify[piece] You better work with Exclusions in ContourPlot

ContourPlot[{Sqrt[sr^2 - sr st + st^2] == 1, Abs[(sr - st)/2] == 1/2,
sr == 1, st == 1, sr == -1, st == -1}, {sr, -2, 2}, {st, -2, 2},
Exclusions -> {{sr == 1, Sqrt[sr^2 - sr st + st^2] <= 1}, {sr == -1,
Sqrt[sr^2 - sr st + st^2] <= 1}, {st == 1,
Sqrt[sr^2 - sr st + st^2] <= 1}, {st == -1,
Sqrt[sr^2 - sr st + st^2] <= 1}}] You can play with PlotPoints and MaxRecursion to fill the gaps.