ContourPlot of an ImplicitRegion defined by the intersecton of equality and inequality

I want to plot a line defined IMPLICITLY by the intersection of an equality and an inequality, i.e. a line that you can't easily simplify (and therefore take advantage of its form). Consider for instance the simple example

R=x > 0 && y == -((5 x)/3)


but assume you don't know which equalities and inequalities it involves (although you know it's a line and not a 2D region).

How can I plot the set R? I can't use RegionPlot as it only consider regions defined by inequalities, but at the same time ContourPlot

ContourPlot[R, {x, -2, 2}, {y, -2, 2}]


does not work.

I know there is the function ImplicitRegion, but

ContourPlot[ImplicitRegion[R, {x, y}], {x, -2, 2}, {y, -2, 2}]


does not work either.

I repeat, do not take advantage of the expressions in R - if you could a solution is to use ContourPlot with RegionFunction.

PS this question is related to Integration over a (non-parametric) curve defined by indicator function

• Is RegionPlot useful ? – b.gates.you.know.what Oct 28 '14 at 12:18
• No, RegionPlot allows only to plot sets defined only by inequalities. – Nicola Oct 28 '14 at 12:20
• RegionPlot+ImplicitRegion works for me. i.stack.imgur.com/e4C9m.png – Rahul Oct 28 '14 at 12:25
• @rhermans I disagree with the close votes. Just because there is a simple answer does not mean it is a simple mistake. I mean my first thought was why doesn't ContourPlot work here. Before the region functionality of V10, RegionPlot would have failed miserably on such a problem. To satisfy the OP's constraint is difficult with ContourPlot. – Michael E2 Feb 17 '16 at 14:14
• @rhermans The region is, in fact, a contour. But the way Mathematica works makes RegionPlot the best approach. It seems to me that if one looks at an object as a contour, one would naturally consider ContourPlot. If other plotters work with regions, why not ContourPlot? (It's not a ground-breaking question to be sure, but I think it passes muster.) Thanks, in any case. – Michael E2 Feb 17 '16 at 22:01

Answer

RegionPlot[ImplicitRegion[R, {x, y}]]


Documentation

ImplicitRegion

RegionPlot

This can easily be done with ContourPlot: you have an equality and an inequality. Put the equality as the argument to ContourPlot and the inequality as the value of the option RegionFunction

ContourPlot[y == -((5 x)/3), {x, -2, 2}, {y, -2, 2},
RegionFunction -> (#1 > 0 &)]


Rahul's comment is the way to do it with ImplicitRegion directly, since RegionPlot is the plotter to use with regions. If a solution in terms of ContourPlot is desired, then a numeric function (or an equivalent equation) describing the region will be needed.

Here is one way to go from ImplicitRegion to ContourPlot.

reg = ImplicitRegion[x > 0 && y == -((5 x)/3), {x, y}];
ysol = Solve[RegionMember[reg, {x, y}], y];
ContourPlot[y == (y /. ysol), {x, -2, 2}, {y, -2, 2}]


There are two obvious limitations: (1) The limitations of Solve, which are more than sufficient for the present task. (2) The the variable to be solved for, y or x, needs to be chosen appropriately in the case of a horizontal or vertical line.

What's going on is that Solve returns a ConditionalExpression that is undefined when x <= 0:

ysol = Solve[RegionMember[reg, {x, y}], y]
(*  {{y -> ConditionalExpression[-((5 x)/3), x > 0]}}  *)