3
$\begingroup$

I have a series of data points describing the boundary of some region. Using ListCurvePathPlot, I have an easy way to get a nice curve interpolating this boundary (rather than splitting the boundary up into "upper" and "lower" curves and using regular function interpolation, which looks much worse). An example is given in the plot below.

My question is: is there an easy way to get the interior region bounded by this to be filled in?

The curve isn't closed but we can easily close off the right hand side.

The data points, together with the curve generated by ListCurvePathPlot

Here is the Plot function analogue of what I want to have for my curve

Plot[{0.5 + x^(1/3), 0.5 - x^(1/3)}, {x, 0, 1}, 
     Filling -> {1 -> {2}}, PlotStyle -> Red]

![enter image description here

Edit: If you want to recreate the first figure as a minimal working example, the points I used are:

points = {{0.557, 0.999072}, {0.7, 0.985086}, {0.69, 0.986477}, 
          {0.6,0.987449}, {0.59, 0.987258}, {0.58, 0.987789}, 
          {0.68, 0.987633}, {0.67, 0.988555}, {0.66, 0.989164}, 
          {0.65, 0.989422}, {0.64, 0.989367}, {0.57, 0.98998}, 
          {0.56, 0.995297}, {0.63, 0.989039}, {0.62, 0.988555}, 
          {0.61, 0.987953}, {0.557, 1.0037}, {0.6, 1.01934}, 
          {0.59, 1.01729}, {0.58, 1.01505}, {0.7, 1.06133}, 
          {0.69, 1.0558}, {0.65, 1.034}, {0.64, 1.02983}, 
          {0.63, 1.02643}, {0.62, 1.0237}, {0.61, 1.02138}, 
          {0.68, 1.05046}, {0.67, 1.04468}, {0.66, 1.03896}, 
          {0.57, 1.01214}, {0.56, 1.00701}};

and the code is simply:

Show[
     ListPlot[{points}, PlotStyle -> Red], 
     ListCurvePathPlot[points, PlotStyle -> {Red, Thick}]]
$\endgroup$
3
  • $\begingroup$ Please, post the code of your problem or, at least, a MWE (minimal working example)... $\endgroup$ Mar 11, 2018 at 19:44
  • $\begingroup$ Posting the list of your points would be worth considering... $\endgroup$
    – gwr
    Mar 11, 2018 at 22:08
  • $\begingroup$ Updated to reflect these suggestions. Thanks. $\endgroup$ Mar 11, 2018 at 22:40

3 Answers 3

4
$\begingroup$
pts = Table[{2 t^2, t}, {t, -1, 1, 0.05}];

path = FindCurvePath[pts][[1]];

Using Graphics

Graphics[{Red, Thick, Line[pts[[path]]], LightRed, Polygon[pts[[path]]]}, 
 Axes -> True]

enter image description here

Using ListCurvePathPlot

ListCurvePathPlot[pts,
 PlotStyle -> {{Red, Thick}},
 Epilog -> {Opacity[.5, LightRed], Polygon[pts[[path]]]}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Yes, this looks like exactly what I was looking for. Thanks! $\endgroup$ Mar 11, 2018 at 22:50
3
$\begingroup$

Does this help?

pts = Table[{2 t^2, t}, {t, -1, 1, 0.05}];
Graphics[
 {
  EdgeForm[], FaceForm[{Darker@Red, Opacity[0.25]}],
  Polygon[pts],
  Thick, Darker@Red,
  Line[pts],
  PointSize[0.02],
  Point[pts]
  },
 Axes -> True
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ This is also helpful. It makes sense that the polygon function would be effective, if the spacing is sufficiently small. I wasn't aware of this function. Thanks! $\endgroup$ Mar 11, 2018 at 22:50
1
$\begingroup$

You can use a function as the PlotStyle option setting to add Points and a Polygon:

ListCurvePathPlot[points, PlotStyle -> 
 ({Red, Thickness[.01], PointSize[Large], #, Yellow, Polygon @@ #, Blue, Point @@ # } &)]

enter image description here

$Version

"11.3.0 for Linux x86 (64-bit) (March 7, 2018)"

Also works in

$Version

"9.0 for Microsoft Windows (64-bit) (January 25, 2013)"

Using the example in Henrik's and Bob's anwers:

pts = Table[{2 t^2, t}, {t, -1, 1, 0.05}]; 
ListCurvePathPlot[pts, PlotStyle -> 
 ({Red, Thickness[.01], PointSize[Large], #, LightRed, Polygon @@ #, Blue, Point @@ #} &)]

enter image description here

And the first example from ListCurvePathPlot :

pts2 = Table[{Cos[t], Sin[t]}, {t, RandomReal[{0, 2 Pi}, 50]}];
ListCurvePathPlot[pts2, PlotStyle -> 
 ({Red, Thickness[.01], PointSize[Large], #, LightRed, Polygon @@ #, Blue, Point @@ #} &)]

enter image description here

$\endgroup$

Your Answer

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

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