2
$\begingroup$

I've searched everywhere for this but can't seem to find a simple way to do this. I have defined a function of two variables and am able to plot a 2D region in the domain space - the endpoints of the domain I specify in RegionPlot - where a certain inequality holds true (f>0).

What I want however is the data represented by the plot region --

  • the data points (x,y) along the 'boundary' of the region would be useful to me.
  • More importantly, getting a list of all the data points inside the region (maybe 100 or 1000 PlotPoints, however fine I can get).

Is there any easy way to do this from the plot? Or from the initial inequality expression that I defined and from a list of the domain of x,y values?

$\endgroup$
0

1 Answer 1

3
$\begingroup$
f[x_, y_] := 2 - Abs[Nest[(#^2 + x + I y) &, x + I y, 8]]; 
rp =  RegionPlot[f[x, y] > 0, {x, -2, 1}, {y, -1.5, 1.5}, 
  PlotStyle -> Orange, ImageSize -> 250];
boundary = Cases[Normal[rp], _Line, Infinity];
Short[boundary, 3]

{Line[{{-0.187294,-1.02632},{-0.184211,-1.09971},<<304>>,{-0.187294,-1.02632}}]}

points = RandomPoint[Polygon @@ boundary[[1]], 100];

Row[{rp, Graphics[{boundary, Red, PointSize[Medium],  Point @ points}, ImageSize -> 250]}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks for your answer. I am getting the {Line[[{{...}}]} output which seems to be giving me the list of boundary points. What exactly does the syntax do? Specifically the arguments in cases? Also, is it possible to convert these points into a set of doublets? From which I would be able to easily access each point or define functions on these points? Finally, I was wondering if it is possible to generate a coarser boundary? If I only wanted a hundred or so points? $\endgroup$ Commented Jun 5, 2018 at 18:34
  • $\begingroup$ Sarah, use coords = Cases[Normal[rp], Line[x_, ___]:>x, Infinity] to get the coordinates of points on the boundary line. (Alternatively, you can use coords = boundary[[1,1]]). $\endgroup$
    – kglr
    Commented Jun 5, 2018 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.