# Simple Region plot with “or” condition (||) does not connect the or parts “smoothly”?

Suppose I want to look at the region defined by the conditions

\begin{align}x\leq y && x<2\\\text{OR}\quad x\geq y&& x\geq2 \end{align}

I plot this using the command

RegionPlot[x <= y  && x < 2 || x >= y && x >= 2, {x, 0, 5}, {y, 0, 5}]


which gives the image below.

Why does this image look the way it does at x=2,y=2, and how can I fix it?

More specifically, I think the regions should only intersect at a point, and should form like a "tilted X". But where the lines cross there is some "width"?

• use the options PlotPoints or MaxRecursion or both , e.g., PlotPoints -> 100], and/or MaxRecursion -> 7? – kglr May 21 '18 at 20:26
• @kglr that indeed fixes it (plotpoints does. Didn't check max recursion). Thank you. – user106860 May 21 '18 at 20:30

## 3 Answers

See Specific initial sample points for 3D plots for some discussion of following form of PlotPoints. Basically throw a point into the offending area and increase MaxRecursion (default value is 2), if needed. If you follow the linked Q&A, you'll realize this approach has a good chance to succeed and a still significant chance that it will fail. It succeeds here if we raise MaxRecursion to 3:

RegionPlot[x <= y && x < 2 || x >= y && x >= 2, {x, 0, 5}, {y, 0, 5},
MaxRecursion -> 3, PlotPoints -> {Automatic, {{2.001, 2.01}}}]


• (+1) I never knew of this extended syntax for PlotPoints! – Chip Hurst May 21 '18 at 23:24

It looks like the default discretization method gives the desired singular vertex:

reg = ImplicitRegion[x <= y && x < 2 || x >= y && x >= 2, {{x, 0, 5}, {y, 0, 5}}];
mesh = BoundaryDiscretizeRegion[reg, Frame -> True]


We can verify this by highlighting the vertices:

HighlightMesh[mesh, Style[0, Red]]


As pointed out in a comment, I can fix it by specifying

PlotPoints ->100


and/or

MaxRecursion-> 7


I guess I just didn't/don't understand how the command worked. I looked at the details of the command and I believe the follows two comments are helpful

• RegionPlot initially evaluates pred at a grid of equally spaced sample points specified by PlotPoints. Then it uses an adaptive algorithm to subdivide at most MaxRecursion times, attempting to find the boundaries of all regions in which pred is True.
• You should realize that since it uses only a finite number of sample points, it is possible for RegionPlot to miss regions in which pred is True. To check your results, you should try increasing the settings for PlotPoints and MaxRecursion.