8
$\begingroup$

Imagine I have a have a set of points that form a closed curve (or simply a circle), I normally just list plot these points and join the dots.

However, I now have the need to fill in this closed area. I could break it into two sets of curves and fill between the result, but let us pretend I have hundreds of these plots to make and want a quicker way.

$\endgroup$
0
16
$\begingroup$

I recommend FilledCurve. Imagine you have a set of points:

pts = {{-1, 0}, {-1, 1}, {0, 0}, {1, 1}, {1, 0}};

Compare smooth curve:

Graphics[{Pink, Thick, BSplineCurve[pts, SplineClosed -> True]}]

enter image description here

To its filled version:

Graphics[{Pink, EdgeForm[Directive[Black, Thick]], 
  FilledCurve[BSplineCurve[pts, SplineClosed -> True]]}]

enter image description here

I guess you need a smooth curve, because for just joined points with a filling inside even Polygon will do - and you get a smooth one with enough points:

bsf = BSplineFunction[pts, SplineClosed -> True];
dat = Table[bsf[t], {t, 0, 1, .01}];
Graphics[{Pink, EdgeForm[Directive[Black, Thick]], Polygon[dat]}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Great, thanks for this, now I just need to make it work well with Log plots... $\endgroup$ – Jay Feb 7 '13 at 1:55

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