3
$\begingroup$

Does the Mathematica graphics system have any concept of intersecting regionplots? I've found about intersecting graphics but not regionplots so far. For example, if I want to show the intersection of these 2 regionplots:

RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}]
RegionPlot[x < 0.5, {x, -2, 2}, {y, -2, 2}]

I know I can use Opacity and place both regionplots on top of each other using:

PLOT1 = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2},PlotStyle -> {Yellow, Opacity[0.2]}, BoundaryStyle -> Directive[Yellow, Thick]]
PLOT2 = RegionPlot[x < 0.5, {x, -2, 2}, {y, -2, 2},PlotStyle -> {Red, Opacity[0.05]}, BoundaryStyle -> Directive[Red]]
Show[PLOT1, PLOT2, LabelStyle -> Directive[FontSize -> 20]]

enter image description here

Or more simply:

RegionPlot[{x^2 + y^3 < 2, x < 0.5}, {x, -2, 2}, {y, -2, 2},PlotLegends->{"PLOT1", "PLOT2"}]

enter image description here However the common regions become less visible the more regionplots I want to intersect. I would like to exclude everything that is not part of the intersection and obtain this:

enter image description here

I know that I could write:

RegionPlot[x^2 + y^3 < 2 && x < 0.5, {x, -2, 2}, {y, -2, 2}]

OR

A = x^2 + y^3 < 2
B = x < 0.5;
RegionPlot[And[A, B], {x, -2, 2}, {y, -2, 2}]

But if A and B are heavier expressions, or that I want to find the intersection of more than 2 regionplots, the calculations can become too heavy.

Is there a way, in my example, to draw separately RegionPlot1 and RegionPlot2 (the way I started with Opacity) and then get a unique RegionPlot but showing only the region where the 2 regionplots intersect (I wish there was a function 'RegionPlotIntersection[PLOT1,PLOT2]')?

Thanks a lot in advance.

So thank you so much for your comments! These functions were not on Mathematica 9 so I got Mathematica 10. Indeed, I get the graphic of the intersection using ImplicitRegion, RegionIntersection and BoundaryDiscretizedRegion!

PLOT1 = ImplicitRegion[x^2 + y^3 < 2, {{x, -2, 2}, {y, -2, 2}}];
PLOT2 = ImplicitRegion[x < 0.5, {{x, -2, 2}, {y, -2, 2}}];
BoundaryDiscretizeRegion[RegionIntersection[PLOT1,PLOT2]]

OR, what can be better sharing the weight of calculations among the 3 steps:

PLOT1=BoundaryDiscretizeRegion[ImplicitRegion[x^2 + y^3 < 2, {{x, -2, 2}, {y, -2, 2}}]];
PLOT2=BoundaryDiscretizeRegion[ImplicitRegion[x < 0.5, {{x, -2, 2}, {y, -2, 2}}]];
RegionIntersection[PLOT1,PLOT2]

enter image description here

And pretty neat, it works with more than 2 regionplots!

PLOT1 = ImplicitRegion[x^2 + y^3 < 2, {{x, -2, 2}, {y, -2, 2}}];
PLOT2 = ImplicitRegion[x < 0.5, {{x, -2, 2}, {y, -2, 2}}];
PLOT3 = ImplicitRegion[y > 0, {{x, -2, 2}, {y, -2, 2}}];
BoundaryDiscretizeRegion[RegionIntersection[PLOT1,PLOT2,PLOT3]]

enter image description here

NEW ADDITIONAL QUESTION: I get a naked graphic and I can't find the equivalent of 'AxesLabel' for discretized graphic, is there a way to keep the axes and values?

Answer: I didn't find something working including DiscretizeRegion and FrameLabel, but I keep the frame if I use RegionPlot instead:

PLOT1 = ImplicitRegion[x^2 + y^3 < 2, {{x, -2, 2}, {y, -2, 2}}];
PLOT2 = ImplicitRegion[x < 0.5, {{x, -2, 2}, {y, -2, 2}}];
RegionPlot[RegionIntersection[PLOT1,PLOT2],PlotRange->{{-2,2},{-2,2}}]
PLOT3 = ImplicitRegion[y > 0, {{x, -2, 2}, {y, -2, 2}}];
RegionPlot[RegionIntersection[PLOT1,PLOT2,PLOT3],PlotRange->{{-2,2},{-2,2}}]

enter image description here enter image description here

My only concern is that I'm not entirely sure that I'm splitting the calculations for Mathematica. In terms on weight of calculations, I'm wondering whether it's not the same as writing:

PLOT = ImplicitRegion[x^2 + y^3 < 2 && x < 0.5 && y > 0, {{x, -2, 2}, {y, -2, 2}}];
$\endgroup$

closed as off-topic by MarcoB, user9660, Yves Klett, m_goldberg, Öskå Mar 11 '16 at 18:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Community, Yves Klett, m_goldberg, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    $\begingroup$ Probably it could help to share the code that define your regions so we can experience the problem. Would Reduce[And[A, B]] help? Did you try DiscretizeRegion? $\endgroup$ – rhermans Aug 24 '15 at 17:59
  • 2
    $\begingroup$ Could you use a combination of RegionIntersection and ImplicitRegions? $\endgroup$ – MarcoB Aug 24 '15 at 19:44
  • 1
    $\begingroup$ Look up Frame and FrameLabel. $\endgroup$ – J. M. is away Aug 25 '15 at 5:57
  • $\begingroup$ RegionPlot can handle more than one region: RegionPlot[{x < 0.5, x^2 + y^3 < 2}, {x, -2, 2}, {y, -2, 2}, PlotLegends -> Automatic] $\endgroup$ – Bob Hanlon Aug 25 '15 at 12:27
  • $\begingroup$ Thank you, it's actually a better way than with Opacity but my question here was to keep only the intersecting region(s). $\endgroup$ – Elsa Aug 25 '15 at 16:11