Skip to main content
2 of 3
expanded to actually answer the question
gpap
  • 9.8k
  • 3
  • 25
  • 67

The "canonical" way is to find a pattern (here, {Black, Thick}) that matches what the boundary is made of and extract it from the graphics object. So given

pt = RegionPlot[{{x^3 - y^2 > 2 y && 
     x^2 + y^3 > 2 x}, {x^3 - y^2 < 2 y && x^2 + y^3 > 2 x}}, {x, -1, 
   1}, {y, -1, .1}, PlotStyle -> {Green, Yellow}, 
  BoundaryStyle -> {Black, Thick}];

bdy=Cases[Normal@First@pt, {Black, Thick, __}, Infinity];

Graphics[bdy]

enter image description here

---EDIT---

In diagonally reading your question, I missed the requirement for the boundary between the two.

The following will work on the particular dataset. First, you can extract the points from the bdy:

points = Cases[bdy, Line[a___] -> a, Infinity]

and you will notice that there are two components each corresponding to one region. Now a nearest function on one set of points applied to the second should give you their boundary:

With[{nf = Nearest[points[[2]]]}, 
 Show[Graphics[{Blue, PointSize -> Large, 
    Point[Flatten[nf /@ points[[1]], 1]]}], 
  Graphics[{Red, PointSize -> Small, Point[points[[2]]]}]]
 ]

enter image description here

(and interchanging the components should yield more or less the same result)

With[{nf = Nearest[points[[1]]]}, 
 Show[Graphics[{Blue, PointSize -> Large, 
    Point[Flatten[nf /@ points[[2]], 1]]}], 
  Graphics[{Red, PointSize -> Small, Point[points[[1]]]}]]
 ]

enter image description here

so now you have the boundary points to fit to a model of your liking or interpolate or whatever you want:

With[{nf = Nearest[points[[2]]]}, 
 bdy = Flatten[nf /@ points[[2]], 1]];
 bdy = First /@ GatherBy[bdy, First] (* so that there are no duplicate x coords);
 ]

i.e.

fit = Interpolation[bdy, InterpolationOrder -> 1];

Plot[fit[x], {x, -1, 0},  
 Epilog -> {Red, PointSize -> Tiny, Point[points[[1]]~Join~points[[2]]]},
  PlotStyle -> {Blue, Thick}]

enter image description here

gpap
  • 9.8k
  • 3
  • 25
  • 67