# How do I fill in a circle made by ParametricPlot with one solid color?

I have a very simple question but I am new with Mathematica. I made a circle on a parametric plot and I made the line black. I want to make the inside of the circle on the parametric plot red. So the result: A red-filled circle with a black outline on an x and y axis (Parametric Plot)

Code:

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}, PlotStyle -> Black]

-
You were asking about ParametricPlot[], but I presume you are aware of the Circle[] and Disk[] primitives? – J. M. Sep 19 '12 at 8:49

One simple way to go about it:

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}] /.
Line[l_List] :> {{Red, Polygon[l]}, {Black, Line[l]}}


If you want the border to be a tad more prominent:

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}] /.
Line[l_List] :> {{Red, Polygon[l]}, {Directive[AbsoluteThickness[3], Black], Line[l]}}


An alternative would be

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}] /.
l_Line :> {EdgeForm[Directive[AbsoluteThickness[3], Black]], Red, FilledCurve[l]}


(after some prompting by Sjoerd)

All three snippets act by replacing any Line[] object produced by ParametricPlot[], via ReplaceAll[] (/.) and RuleDelayed[] (:>). With the first two, the instruction reads as "replace any Line[]s present with a Red Polygon[] (for filling the inside) and a Black Line[] (with a thickening through AbsoluteThickness[] in the second version)", the Polygon[] object coming first in the right-hand side of the RuleDelayed[] so that it is rendered first before the Line[].

The third version makes use of the FilledCurve[] primitive, which is new in version eight. EdgeForm[] is used to make the edges of the FilledCurve[] object black and thick, and Red colors the filling red.

-
Nice point! But it didn't works on With[{n = 5}, ParametricPlot[{Sin[n u] Cos[u], Sin[n u] Sin[u]}, {u, 0, 2 Pi}] /. Line[l_List] :> {{Red, Polygon[l]}, {Black, Line[l]}}] if OddQ n. – chyaong Dec 23 '12 at 7:07
@chyanog, that's because your curve is self-intersecting. The solution presented here won't work for that case. – J. M. Apr 10 '13 at 18:06

ListLinePlot[Table[{Cos[u], Sin[u]}, {u, 0, 2 Pi, .05}],
PlotStyle -> {Thick, Black}, Filling -> Axis, FillingStyle -> Red,
AspectRatio -> 1, Axes -> None, Frame -> True]


If you insist on ParametricPlot

Show[ParametricPlot[{{r Cos[u], r Sin[u]}}, {u, 0, 2 Pi}, {r, 0, 1},
PerformanceGoal -> "Quality", Mesh -> 0,
ColorFunction -> Function[{x, y, u, v}, Red],
ColorFunctionScaling -> False, BoundaryStyle -> None,
Exclusions -> {Cos[u] == 1}, Axes -> False, ExclusionsStyle -> Red],
ParametricPlot[{{ Cos[u], Sin[u]}}, {u, 0, 2 Pi},
PerformanceGoal -> "Quality",
PlotStyle -> Directive[Black, Thickness[0.01]], Axes -> False]]


-
It's a tad simpler to do ColorFunction -> (Red &)... – J. M. Sep 19 '12 at 9:16
@J.M. I copied directly from the Doc.. As I grow older my brain is behaving more like the Nokia stock.. – PlatoManiac Sep 19 '12 at 9:38
Note the use of ColorFunction is disabling anti-aliasing. – Chris Degnen Sep 19 '12 at 10:48
@ChrisDegnen is there a way to keep the anti-aliasing ok while using ColorFunction... – PlatoManiac Sep 19 '12 at 14:37
I couldn't find a way. The examples on RegionPlot that use ColorFunction don't have anti-aliasing either, at least on 7.0.1. – Chris Degnen Sep 19 '12 at 15:55

Two-parameter ParametricPlot with Exclusions:

 ParametricPlot[{r Cos[t], r Sin[t]}, {t, 0, 2 Pi}, {r, 0, 1},
Mesh -> None, PlotStyle -> Directive[Red, Opacity[1]],
Exclusions -> {r == 1},
ExclusionsStyle -> Directive[EdgeForm[{AbsoluteThickness[3], Black}]],
BoundaryStyle -> None, (* thanks to J.M.'s comment *)
PlotPoints -> 100]


-
Maybe include BoundaryStyle -> None to get rid of that blue line covering up the positive $x$-axis? – J. M. Sep 19 '12 at 10:00
@J.M. Thank you; didn't even notice till your comment -- now I "see". AxesStyle -> AbsoluteThickness[15] also works:) – kglr Sep 19 '12 at 10:16

Using Show with a parametric region plot and a parametric curve plot:

Show[
ParametricPlot[v {Cos[u], Sin[u]}, {u, 0, 2 Pi}, {v, 0, 1},
Mesh -> False, PlotStyle -> Directive[Red, Opacity[1]],
BoundaryStyle -> None],
ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi},
PlotStyle -> {AbsoluteThickness[8], Black}],
Frame -> False, Axes -> False, ImageSize -> 240]


-
I was about to suggest using BoundaryStyle -> Black, but then thought to try to remove the axes first... there's a radius cutting into the circle. Maybe include BoundaryStyle -> None in the options? – J. M. Sep 19 '12 at 9:14
PlotStyle->Directive[Opacity[1],Red] gets rid of the default opacity (Opacity[0.2]). – kglr Sep 19 '12 at 10:23

Using Cases to extract plot data:

ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}] //
Cases[#, Line[x_] -> x, Infinity] & //
Graphics[{EdgeForm[{Black, Thick}], Red, Polygon[First@#]}, Axes -> 1] &

-

Great question. Too bad I missed it until today. Anyway, after viewing the existing solutions I think have something to offer. It is a variation of Chris Degnen's method, but I control Mesh instead of using a second plot and give a simpler form for PlotStyle.

ParametricPlot[v {Cos[u], Sin[u]}, {u, 0, 2.1 Pi}, {v, 0, 1},
Mesh -> {0, {1}},
MeshStyle -> Thick,
PlotStyle -> Opacity[1, Red],
BoundaryStyle -> None,
Axes -> None
]


-