Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how fill PolarPlot?

357 views
Skip to first unread message

Murray Eisenberg

unread,
Dec 23, 2007, 4:34:21 AM12/23/07
to
I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:

PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]

How can I fill the inside -- or, what I really want, just the leaf in
the right half-plane -- with some color?

I note that Filling does not seem to be an option for PolarPlot (or for
what would be almost as good, ParametricPlot).

I tried including the following (obtained by converting from :

Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y,-1,1},
Frame->False, AspectRatio->Automatic]

However, that led to a mysterious error message:

$Aborted is not a Graphics primitive or directive.

(Perhaps because of an incompatibility of a Prolog with cartesian
coordinates inside a polar coordinate plot??)

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Steve Luttrell

unread,
Dec 24, 2007, 4:41:42 AM12/24/07
to
If you reformulate your problem as Abs[Cos[\[Theta]]^2-Sin[\[Theta]]^2] >
r^2 then this does what you want:

RegionPlot[Abs[(x^2-y^2)/(x^2+y^2)]>Sqrt[x^2+y^2],{x,-1,1},{y,-1,1}]

Stephen Luttrell
West Malvern, UK

"Murray Eisenberg" <mur...@math.umass.edu> wrote in message
news:fkla2t$3sh$1...@smc.vnet.net...

Andrzej Kozlowski

unread,
Dec 24, 2007, 4:42:48 AM12/24/07
to
On 23 Dec 2007, at 18:34, Murray Eisenberg wrote:

> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>
> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>
> How can I fill the inside -- or, what I really want, just the leaf in
> the right half-plane -- with some color?
>
> I note that Filling does not seem to be an option for PolarPlot (or
> for
> what would be almost as good, ParametricPlot).
>
> I tried including the following (obtained by converting from :
>
> Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},
> {y,-1,1},
> Frame->False, AspectRatio->Automatic]
>
> However, that led to a mysterious error message:
>
> $Aborted is not a Graphics primitive or directive.
>
> (Perhaps because of an incompatibility of a Prolog with cartesian
> coordinates inside a polar coordinate plot??)
>
> --
> Murray Eisenberg mur...@math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2859 (W)
> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305
>


How about simply:


s1 = PolarPlot[Cos[2 theta], {theta, -Pi/4, Pi/4}] /. Line -> Polygon;
s2 = PolarPlot[Cos[2 theta], {theta, Pi/2, Pi/2 + Pi/4}] /. Line ->
Polygon;
s3 = PolarPlot[Cos[2 theta], {theta, 3 Pi/2 - Pi/4, 3 Pi/2}] /.Line ->
Polygon;

Show[ss, s1, s2, s3]


Andrzej Kozlowski

Szabolcs Horvát

unread,
Dec 24, 2007, 4:43:49 AM12/24/07
to
Murray Eisenberg wrote:
> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>
> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>
> How can I fill the inside -- or, what I really want, just the leaf in
> the right half-plane -- with some color?
>

Hi,

Try this using ParametricPlot with two variables:

ParametricPlot[
Cos[2 theta] {Cos[theta], Sin[theta]} r, {theta, 0, 2 Pi}, {r, 0, 1},
Mesh -> False, PlotPoints -> {30, 2}]

For only filling the right-side leaf, there are probably better ways,
but this works too:

g1 = PolarPlot[Cos[2 theta], {theta, Pi/4, 2 Pi - Pi/4}]
g2 = ParametricPlot[
Cos[2 theta] {Cos[theta], Sin[theta]} r, {theta, -Pi/4, Pi/4},
{r, 0, 1}, Mesh -> False]
Show[g1, g2, PlotRange -> All]

I hope this helps,
Szabolcs

Murray Eisenberg

unread,
Dec 24, 2007, 4:45:51 AM12/24/07
to
I was finally able to do this with Epilog->{Inset[RegionPlot[...]]}.

Below is the entire code for the embellished plot I wanted. I am still
unhappy with at the amount of work I had to do in order to adjust the
ImageSize of the filled leaf and the thickness of its boundary so as to
cover up the underlying blue boundary of that leaf from the PolarPlot.

Some of that adjustment could probably be avoided by using a
ColorFunction for the overall POlarPlot. But how does one set up
ColorFunction for PolarPlot so as to specify using, say, one color for
part of the plot and another for another part, depending on the value of
theta alone?

I found no example of ColorFunction in the documentation. I tried, e.g.,

PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
ColorFunction ->
Function[{theta,r}, If[-Pi/4 <= theta <= Pi/4, Red, Black]]]

but that doesn't work as expected.

The finished figure's code:

txt[t_,{x_,y_}]:=Style[Text[t,{x,y}],FontSize->30,FontWeight->Bold]
{xmin,xmax}={-1.425,1.425}; {ymin,ymax}={-1.25,1.25};

PolarPlot[Cos[2t],{t,0,2Pi}, PlotRange->{{xmin,xmax},{ymin,ymax}},
PlotStyle->{ColorData["Legacy","SteelBlue"], Thickness[0.007]},
Ticks->None,

Epilog->{
Inset[RegionPlot[(x^2+y^2)^(3/2)<=x^2-y^2,{x,-0.02,1},{y,-1,1},
PlotStyle->ColorData["HTML","Gold"],
BoundaryStyle->Directive[Thickness[0.025],
ColorData["Legacy","CadmiumOrange"]],
Frame->False,AspectRatio->Automatic,
ImageSize->2.6*72],
{0.5,0}],
Black,Thick,Dashing[{0.045,0.03}],
Line[{{0,0},{0.85,0.85}}],Line[{{0,0},{0.85,-0.85}}],
Dashing[{}],Thick,
Arrow[{{xmin,0},{xmax,0}}],Arrow[{{0,ymin},{0,ymax}}],
txt[TraditionalForm[HoldForm[r==cos 2t ]],{-0.6,1.0}],
txt[TraditionalForm[HoldForm[t==Pi/4]],{1.125,0.925}],
txt[TraditionalForm[HoldForm[t==-Pi/4]],{1.125,-0.99}]
},
ImageSize->7*72]

Murray Eisenberg wrote:
> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>
> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>
> How can I fill the inside -- or, what I really want, just the leaf in
> the right half-plane -- with some color?
>

Helen Read

unread,
Dec 24, 2007, 4:47:53 AM12/24/07
to
Murray Eisenberg wrote:
> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>
> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>
> How can I fill the inside -- or, what I really want, just the leaf in
> the right half-plane -- with some color?
>
> I note that Filling does not seem to be an option for PolarPlot (or for
> what would be almost as good, ParametricPlot).
>
> I tried including the following (obtained by converting from :
>
> Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y,-1,1},
> Frame->False, AspectRatio->Automatic]
>
> However, that led to a mysterious error message:
>
> $Aborted is not a Graphics primitive or directive.

I got the even more mysterious error "Graphics is not a Graphics
primitive or directive".

> (Perhaps because of an incompatibility of a Prolog with cartesian
> coordinates inside a polar coordinate plot??)

Don't know, but in any case the following works.

Show[PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}],


RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2, {x, -0.02, 1}, {y, -1, 1},

Frame -> False, AspectRatio -> Automatic]]


--
Helen Read
University of Vermont

Bill Rowe

unread,
Dec 24, 2007, 4:48:57 AM12/24/07
to
On 12/23/07 at 4:34 AM, mur...@math.umass.edu (Murray Eisenberg)
wrote:

>I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:

>PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]

>How can I fill the inside -- or, what I really want, just the leaf
>in the right half-plane -- with some color?

>I note that Filling does not seem to be an option for PolarPlot (or
>for what would be almost as good, ParametricPlot).

>I tried including the following (obtained by converting from :

>Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2,
>{x,-0.02,1},{y,-1,1}, Frame->False, AspectRatio->Automatic]

>However, that led to a mysterious error message:

>$Aborted is not a Graphics primitive or directive.

>(Perhaps because of an incompatibility of a Prolog with cartesian


>coordinates inside a polar coordinate plot??)

I don't know what causes the error message but I do not believe
it is the issue of cartesian coordinates versus polar
coordinates since the following works with no error messages

PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}, AspectRatio -> Automatic,
Prolog ->
Inset[RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2, {x, -0.02,


1}, {y, -1, 1},

Frame -> False, AspectRatio -> Automatic], {0, 0}, {0, 0}, 1.06]]

The only aspect of the the code above I do not understand is
the necessity of setting the last size argument to Inset to
1.06. I would have expected this to be 1. But that results in a
plot where the right leaf is not completely colored in.
--
To reply via email subtract one hundred and four

Jaccard Florian

unread,
Dec 24, 2007, 4:53:07 AM12/24/07
to
Hello Murray,

I would do it like that :

Show[{des = PolarPlot[Cos[2*theta], {theta, 0, 2*Pi}],
des /. Line[a_] -> {Yellow, Polygon[a]}, des}]

I'm convinced it is a very simple way to fill PolarPlot.
But I agree it would be a good option to add to PolarPlot!

Merry Christmas and a happy new year wishes you

Florian Jaccard

-----Message d'origine-----
De=A0: Murray Eisenberg [mailto:mur...@math.umass.edu]
Envoy=E9=A0: dimanche, 23. d=E9cembre 2007 10:35
=C0=A0: math...@smc.vnet.net
Objet=A0: how fill PolarPlot?

I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:

PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]

How can I fill the inside -- or, what I really want, just the leaf in
the right half-plane -- with some color?

I note that Filling does not seem to be an option for PolarPlot (or for
what would be almost as good, ParametricPlot).

I tried including the following (obtained by converting from :

Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, =


{x,-0.02,1},{y,-1,1},
Frame->False, AspectRatio->Automatic]

However, that led to a mysterious error message:

$Aborted is not a Graphics primitive or directive.

(Perhaps because of an incompatibility of a Prolog with cartesian
coordinates inside a polar coordinate plot??)

--

Bob Hanlon

unread,
Dec 24, 2007, 4:54:09 AM12/24/07
to
Show[{
RegionPlot[(x^2 + y^2)^(1/2) <= Cos[2 ArcTan[y/x]],
{x, 0, 1}, {y, -1/2, 1/2}],
PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
PlotStyle -> Red]},
PlotRange -> All]

Show[{


RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2,

{x, 0, 1}, {y, -1/2, 1/2}],
PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
PlotStyle -> Red]},
PlotRange -> All]


Bob Hanlon

---- Murray Eisenberg <mur...@math.umass.edu> wrote:
> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>
> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>
> How can I fill the inside -- or, what I really want, just the leaf in
> the right half-plane -- with some color?
>
> I note that Filling does not seem to be an option for PolarPlot (or for
> what would be almost as good, ParametricPlot).
>
> I tried including the following (obtained by converting from :
>

> Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y,-1,1},

David Park

unread,
Dec 24, 2007, 4:57:15 AM12/24/07
to
Here is a solution using the Presentations package. We draw the filled right
leaf in the theta-r plane and then we transform it to the x-y plane using
DrawingTransform and combine it with the outline of the other three leafs.

Needs["Presentations`Master`"]

Module[
{rightleaf =
Draw[Cos[2 theta], {theta, -Pi/4, Pi/4}, Filling -> Axis,
FillingStyle -> Orange]},
Draw2D[
{rightleaf /. DrawingTransform[#2 Cos[#1] &, #2 Sin[#1] &],
PolarDraw[Cos[2 theta], {theta, Pi/4, 7 Pi/4}]},
Frame -> True,
ImageSize -> 300]
]


--
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/


"Murray Eisenberg" <mur...@math.umass.edu> wrote in message
news:fkla2t$3sh$1...@smc.vnet.net...

dfl...@rcn.com

unread,
Dec 24, 2007, 4:58:17 AM12/24/07
to
How about

Module[{leaf, clover},
leaf = FullGraphics@


RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2, {x, -0.02, 1}, {y, -1,

1}, Frame -> False, AspectRatio -> Automatic];
clover = PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}];
Show[{leaf, clover}]
]

Or you could use

Module[{leaf, clover},
leaf = RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2, {x, -0.02,
1}, {y, -1, 1}, Frame -> False, AspectRatio -> Automatic];
clover = PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}];
Show[{leaf, clover}, PlotRange -> All]
]

But for some reason on my machine the second plot is not anti-aliased.
I am not really clear on when and where Mathematica uses anti-
aliasing, but I wish it was more consistent.

When using Prolog I didn't get the same error message as you did.
Instead the error was:

"Graphics is not a Graphics primitive or directive"

I am using Mathematica 6.0.1 on Mac OS X 10.4.10

Dan

On Dec 23, 4:34=A0am, Murray Eisenberg <mur...@math.umass.edu> wrote:
> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>

> =A0 =A0PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]


>
> How can I fill the inside -- or, what I really want, just the leaf in
> the right half-plane -- with some color?
>
> I note that Filling does not seem to be an option for PolarPlot (or for
> what would be almost as good, ParametricPlot).
>
> I tried including the following (obtained by converting from :
>

> =A0 =A0Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y,-=
1,1},
> =A0 =A0 =A0 =A0Frame->False, AspectRatio->Automatic]


>
> However, that led to a mysterious error message:
>

> =A0 =A0$Aborted is not a Graphics primitive or directive.


>
> (Perhaps because of an incompatibility of a Prolog with cartesian
> coordinates inside a polar coordinate plot??)
>
> --

> Murray Eisenberg =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mur...@math.umass=


.edu
> Mathematics & Statistics Dept.

> Lederle Graduate Research Tower =A0 =A0 =A0phone 413 549-1020 (H)
> University of Massachusetts =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0413 545-2859 (W=
)
> 710 North Pleasant Street =A0 =A0 =A0 =A0 =A0 =A0fax =A0 413 545-1801
> Amherst, MA 01003-9305


Murray Eisenberg

unread,
Dec 24, 2007, 5:00:21 AM12/24/07
to
Yes, that does it, thank you. But I'm still puzzled as to why I cannot
use the Prolog as I gave it to do the filled right-hand leaf.

Bob Hanlon wrote:
> Show[{
> RegionPlot[(x^2 + y^2)^(1/2) <= Cos[2 ArcTan[y/x]],
> {x, 0, 1}, {y, -1/2, 1/2}],
> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
> PlotStyle -> Red]},
> PlotRange -> All]
>
> Show[{

> RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2,

> {x, 0, 1}, {y, -1/2, 1/2}],

> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
> PlotStyle -> Red]},
> PlotRange -> All]
>
>
> Bob Hanlon
>

> ---- Murray Eisenberg <mur...@math.umass.edu> wrote:
>> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>>

>> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>>

>> How can I fill the inside -- or, what I really want, just the leaf in
>> the right half-plane -- with some color?
>>
>> I note that Filling does not seem to be an option for PolarPlot (or for
>> what would be almost as good, ParametricPlot).
>>
>> I tried including the following (obtained by converting from :
>>

>> Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y,-1,1},


>> Frame->False, AspectRatio->Automatic]
>>
>> However, that led to a mysterious error message:
>>

>> $Aborted is not a Graphics primitive or directive.
>>
>> (Perhaps because of an incompatibility of a Prolog with cartesian
>> coordinates inside a polar coordinate plot??)
>>
>> --

>> Murray Eisenberg mur...@math.umass.edu
>> Mathematics & Statistics Dept.


>> Lederle Graduate Research Tower phone 413 549-1020 (H)
>> University of Massachusetts 413 545-2859 (W)

>> 710 North Pleasant Street fax 413 545-1801
>> Amherst, MA 01003-9305
>>
>

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.


Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)

710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Murray Eisenberg

unread,
Dec 25, 2007, 5:18:59 AM12/25/07
to
That does not show the entire four-leaved rose together with a shaded
leaf in the right half-plane.

What I'm seeing is a shaded leaf in the right half-plane along with
shaded pieces of the top and bottom leaves that stick into the right
half-plane and are within the top and bottom boundaries of the
right-hand leaf.

Andrzej Kozlowski wrote:


>
> On 23 Dec 2007, at 18:34, Murray Eisenberg wrote:
>
>> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>>
>> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>>
>> How can I fill the inside -- or, what I really want, just the leaf in
>> the right half-plane -- with some color?
>>
>> I note that Filling does not seem to be an option for PolarPlot (or for
>> what would be almost as good, ParametricPlot).
>>
>> I tried including the following (obtained by converting from :
>>
>> Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y,-1,1},
>> Frame->False, AspectRatio->Automatic]
>>
>> However, that led to a mysterious error message:
>>
>> $Aborted is not a Graphics primitive or directive.
>>
>> (Perhaps because of an incompatibility of a Prolog with cartesian
>> coordinates inside a polar coordinate plot??)
>>
>> --
>> Murray Eisenberg mur...@math.umass.edu
>> Mathematics & Statistics Dept.
>> Lederle Graduate Research Tower phone 413 549-1020 (H)
>> University of Massachusetts 413 545-2859 (W)
>> 710 North Pleasant Street fax 413 545-1801
>> Amherst, MA 01003-9305
>>
>
>

> How about simply:
>
>
> s1 = PolarPlot[Cos[2 theta], {theta, -Pi/4, Pi/4}] /. Line -> Polygon;
> s2 = PolarPlot[Cos[2 theta], {theta, Pi/2, Pi/2 + Pi/4}] /. Line ->
> Polygon;
> s3 = PolarPlot[Cos[2 theta], {theta, 3 Pi/2 - Pi/4, 3 Pi/2}] /.Line ->
> Polygon;
>
> Show[ss, s1, s2, s3]
>
>
> Andrzej Kozlowski
>

--

Bob Hanlon

unread,
Dec 25, 2007, 5:20:01 AM12/25/07
to
Because Prolog needs a list of graphics primitives. Use

PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}, PlotStyle -> Red,
Prolog ->

RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2, {x, 0, 1}, {y, -1/2,

1/2}][[1]]]


Bob Hanlon

---- Murray Eisenberg <mur...@math.umass.edu> wrote:
> Yes, that does it, thank you. But I'm still puzzled as to why I cannot
> use the Prolog as I gave it to do the filled right-hand leaf.
>
> Bob Hanlon wrote:
> > Show[{
> > RegionPlot[(x^2 + y^2)^(1/2) <= Cos[2 ArcTan[y/x]],
> > {x, 0, 1}, {y, -1/2, 1/2}],
> > PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
> > PlotStyle -> Red]},
> > PlotRange -> All]
> >
> > Show[{
> > RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2,
> > {x, 0, 1}, {y, -1/2, 1/2}],
> > PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
> > PlotStyle -> Red]},
> > PlotRange -> All]
> >
> >
> > Bob Hanlon
> >

Andrzej Kozlowski

unread,
Dec 25, 2007, 6:25:22 AM12/25/07
to
Well, I misunderstood you, but it is trivial to fix this:

s = PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}];


s1 = PolarPlot[Cos[2 theta], {theta, -Pi/4, Pi/4}] /. Line -> Polygon;

Show[s, s1]

Andrzej Kozlowski


On 24 Dec 2007, at 18:50, Murray Eisenberg wrote:

> That does not show the entire four-leaved rose together with a shaded
> leaf in the right half-plane.
>
> What I'm seeing is a shaded leaf in the right half-plane along with
> shaded pieces of the top and bottom leaves that stick into the right
> half-plane and are within the top and bottom boundaries of the
> right-hand leaf.
>
> Andrzej Kozlowski wrote:
>>

>> On 23 Dec 2007, at 18:34, Murray Eisenberg wrote:
>>
>>> I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>>>
>>> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
>>>
>>> How can I fill the inside -- or, what I really want, just the leaf
>>> in
>>> the right half-plane -- with some color?
>>>
>>> I note that Filling does not seem to be an option for PolarPlot
>>> (or for
>>> what would be almost as good, ParametricPlot).
>>>
>>> I tried including the following (obtained by converting from :
>>>
>>> Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},
>>> {y,-1,1},
>>> Frame->False, AspectRatio->Automatic]
>>>
>>> However, that led to a mysterious error message:
>>>
>>> $Aborted is not a Graphics primitive or directive.
>>>
>>> (Perhaps because of an incompatibility of a Prolog with cartesian
>>> coordinates inside a polar coordinate plot??)
>>>
>>> --
>>> Murray Eisenberg mur...@math.umass.edu
>>> Mathematics & Statistics Dept.
>>> Lederle Graduate Research Tower phone 413 549-1020 (H)
>>> University of Massachusetts 413 545-2859 (W)
>>> 710 North Pleasant Street fax 413 545-1801
>>> Amherst, MA 01003-9305
>>>
>>
>>

>> How about simply:
>>
>>
>> s1 = PolarPlot[Cos[2 theta], {theta, -Pi/4, Pi/4}] /. Line ->
>> Polygon;
>> s2 = PolarPlot[Cos[2 theta], {theta, Pi/2, Pi/2 + Pi/4}] /. Line ->
>> Polygon;
>> s3 = PolarPlot[Cos[2 theta], {theta, 3 Pi/2 - Pi/4, 3 Pi/2}] /.Line
>> ->
>> Polygon;
>>
>> Show[ss, s1, s2, s3]
>>
>>
>> Andrzej Kozlowski
>>
>

m...@inbox.ru

unread,
Dec 25, 2007, 6:26:26 AM12/25/07
to
RegionPlot by default has PlotRange -> Full, so the x range is 1.02
and the inset with width 1.02 will be aligned exactly:

PolarPlot[Cos[2 t], {t, 0, 2 Pi}, PlotStyle -> Green,
Epilog -> Inset[RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2,


{x, -0.02, 1}, {y, -1, 1},

AspectRatio -> Automatic, Frame -> False, PlotRangePadding -> 0],
{0, 0}, {0, 0}, 1.02]]

Also you can simply extract the graphics primitives from RegionPlot:

PolarPlot[Cos[2 t], {t, 0, 2 Pi}, PlotStyle -> Green,
Epilog -> First@ RegionPlot[(x^2 + y^2)^(3/2) <= x^2 - y^2,
{x, -0.02, 1}, {y, -1, 1}]]

Maxim Rytin
m...@inbox.ru

On Dec 24, 3:45=A0am, Murray Eisenberg <mur...@math.umass.edu> wrote:
> I was finally able to do this with Epilog->{Inset[RegionPlot[...]]}.
>

> Below is the entire code for the embellished plot I wanted. =A0I am still


> unhappy with at the amount of work I had to do in order to adjust the
> ImageSize of the filled leaf and the thickness of its boundary so as to
> cover up the underlying blue boundary of that leaf from the PolarPlot.
>
> Some of that adjustment could probably be avoided by using a

> ColorFunction for the overall POlarPlot. =A0But how does one set up


> ColorFunction for PolarPlot so as to specify using, say, one color for
> part of the plot and another for another part, depending on the value of
> theta alone?
>

> I found no example of ColorFunction in the documentation. =A0I tried, e.g.=
,
>
> =A0 PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
> =A0 =A0 ColorFunction ->
> =A0 =A0 =A0 Function[{theta,r}, If[-Pi/4 <= theta <= Pi/4, Red, Black]=


]]
>
> but that doesn't work as expected.
>
> The finished figure's code:
>

> =A0 =A0txt[t_,{x_,y_}]:=Style[Text[t,{x,y}],FontSize->30,FontWeight->Bol=
d]
> =A0 =A0{xmin,xmax}={-1.425,1.425}; {ymin,ymax}={-1.25,1.25};
>
> =A0 =A0PolarPlot[Cos[2t],{t,0,2Pi}, PlotRange->{{xmin,xmax},{ymin,ymax}},
> =A0 =A0 =A0PlotStyle->{ColorData["Legacy","SteelBlue"], Thickness[0.007]},=

> =A0 =A0 =A0Ticks->None,
>
> =A0 =A0 =A0Epilog->{
> =A0 =A0 =A0 =A0Inset[RegionPlot[(x^2+y^2)^(3/2)<=x^2-y^2,{x,-0.02,1},{y,=
-1,1},
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PlotStyle->ColorData["HTML","Gold"],
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BoundaryStyle->Directive[Thickness[0.025],
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ColorData["Legacy","CadmiumOrange"]],
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Frame->False,AspectRatio->Automatic,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ImageSize->2.6*72],
> =A0 =A0 =A0 =A0 =A0 {0.5,0}],
> =A0 =A0 =A0 =A0 Black,Thick,Dashing[{0.045,0.03}],
> =A0 =A0 =A0 =A0 Line[{{0,0},{0.85,0.85}}],Line[{{0,0},{0.85,-0.85}}],
> =A0 =A0 =A0 =A0 Dashing[{}],Thick,
> =A0 =A0 =A0 =A0 Arrow[{{xmin,0},{xmax,0}}],Arrow[{{0,ymin},{0,ymax}}],
> =A0 =A0 =A0 =A0 txt[TraditionalForm[HoldForm[r==cos 2t ]],{-0.6,1.0}],=

> =A0 =A0 =A0 =A0 txt[TraditionalForm[HoldForm[t==Pi/4]],{1.125,0.925}],=

> =A0 =A0 =A0 =A0 txt[TraditionalForm[HoldForm[t==-Pi/4]],{1.125,-0.99}]=

> =A0 =A0 =A0},
> =A0 =A0ImageSize->7*72]


>
>
>
> Murray Eisenberg wrote:
> > I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
>

> > =A0 =A0PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]


>
> > How can I fill the inside -- or, what I really want, just the leaf in
> > the right half-plane -- with some color?
>
> > I note that Filling does not seem to be an option for PolarPlot (or for
> > what would be almost as good, ParametricPlot).
>
> > I tried including the following (obtained by converting from :
>

> > =A0 =A0Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y=
,-1,1},
> > =A0 =A0 =A0 =A0Frame->False, AspectRatio->Automatic]


>
> > However, that led to a mysterious error message:
>

> > =A0 =A0$Aborted is not a Graphics primitive or directive.


>
> > (Perhaps because of an incompatibility of a Prolog with cartesian
> > coordinates inside a polar coordinate plot??)
>
> --

> Murray Eisenberg =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mur...@math.umass=
.edu

> Mathematics & Statistics Dept.


> Lederle Graduate Research Tower =A0 =A0 =A0phone 413 549-1020 (H)
> University of Massachusetts =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0413 545-2859 (W=
)

> 710 North Pleasant Street =A0 =A0 =A0 =A0 =A0 =A0fax =A0 413 545-1801
> Amherst, MA 01003-9305

Bob Hanlon

unread,
Dec 25, 2007, 6:30:31 AM12/25/07
to
PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},
ColorFunction ->
Function[{x, y}, If[-Pi/4 <= ArcTan[x, y] <= Pi/4, Red, Blue]],
ColorFunctionScaling -> False]


Bob Hanlon

---- Murray Eisenberg <mur...@math.umass.edu> wrote:
> I was finally able to do this with Epilog->{Inset[RegionPlot[...]]}.
>

> Below is the entire code for the embellished plot I wanted. I am still

> unhappy with at the amount of work I had to do in order to adjust the
> ImageSize of the filled leaf and the thickness of its boundary so as to
> cover up the underlying blue boundary of that leaf from the PolarPlot.
>
> Some of that adjustment could probably be avoided by using a

> ColorFunction for the overall POlarPlot. But how does one set up

> ColorFunction for PolarPlot so as to specify using, say, one color for
> part of the plot and another for another part, depending on the value of
> theta alone?
>

> I found no example of ColorFunction in the documentation. I tried, e.g.,


>
> PolarPlot[Cos[2 theta], {theta, 0, 2 Pi},

> ColorFunction ->
> Function[{theta,r}, If[-Pi/4 <= theta <= Pi/4, Red, Black]]]


>
> but that doesn't work as expected.
>
> The finished figure's code:
>

> txt[t_,{x_,y_}]:=Style[Text[t,{x,y}],FontSize->30,FontWeight->Bold]


> {xmin,xmax}={-1.425,1.425}; {ymin,ymax}={-1.25,1.25};
>

> PolarPlot[Cos[2t],{t,0,2Pi}, PlotRange->{{xmin,xmax},{ymin,ymax}},

> PlotStyle->{ColorData["Legacy","SteelBlue"], Thickness[0.007]},
> Ticks->None,
>
> Epilog->{

> Inset[RegionPlot[(x^2+y^2)^(3/2)<=x^2-y^2,{x,-0.02,1},{y,-1,1},


> PlotStyle->ColorData["HTML","Gold"],

> BoundaryStyle->Directive[Thickness[0.025],
> ColorData["Legacy","CadmiumOrange"]],
> Frame->False,AspectRatio->Automatic,
> ImageSize->2.6*72],
> {0.5,0}],
> Black,Thick,Dashing[{0.045,0.03}],

> Line[{{0,0},{0.85,0.85}}],Line[{{0,0},{0.85,-0.85}}],

> Dashing[{}],Thick,


> Arrow[{{xmin,0},{xmax,0}}],Arrow[{{0,ymin},{0,ymax}}],

> txt[TraditionalForm[HoldForm[r==cos 2t ]],{-0.6,1.0}],

> txt[TraditionalForm[HoldForm[t==Pi/4]],{1.125,0.925}],

> txt[TraditionalForm[HoldForm[t==-Pi/4]],{1.125,-0.99}]

> },


> ImageSize->7*72]
>
> Murray Eisenberg wrote:
> > I Mathematica 6 I have a PolarPlot, e.g., a 4-leaved rose:
> >

> > PolarPlot[Cos[2 theta], {theta, 0, 2 Pi}]
> >
> > How can I fill the inside -- or, what I really want, just the leaf in
> > the right half-plane -- with some color?
> >
> > I note that Filling does not seem to be an option for PolarPlot (or for
> > what would be almost as good, ParametricPlot).
> >
> > I tried including the following (obtained by converting from :
> >

> > Prolog->RegionPlot[(x^2 + y^2)^(3/2) <= x^2-y^2, {x,-0.02,1},{y,-1,1},


> > Frame->False, AspectRatio->Automatic]
> >
> > However, that led to a mysterious error message:
> >

> > $Aborted is not a Graphics primitive or directive.
> >
> > (Perhaps because of an incompatibility of a Prolog with cartesian
> > coordinates inside a polar coordinate plot??)
> >
>
> --

> Murray Eisenberg mur...@math.umass.edu
> Mathematics & Statistics Dept.


> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2859 (W)

> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305
>


Murray Eisenberg

unread,
Dec 25, 2007, 6:31:34 AM12/25/07
to
Your response suggests that perhaps it's not possible directly to use
polar coordinates themselves as arguments to the ColorFunction function.

If so, that's a shame.

Murray Eisenberg

unread,
Dec 25, 2007, 6:34:39 AM12/25/07
to
Many thanks to all who replied, showing a variety of methods to
accomplish what I wanted. Very instructive!

Brett Champion

unread,
Dec 26, 2007, 5:09:55 AM12/26/07
to
On Dec 25, 2007, at 5:28 AM , Murray Eisenberg wrote:

> Your response suggests that perhaps it's not possible directly to use
> polar coordinates themselves as arguments to the ColorFunction
> function.
>
> If so, that's a shame.
>

From the PolarPlot documentation:

"The arguments supplied to functions in MeshFunctions and
RegionFunction are x, y, \[Theta], r. Functions in ColorFunction
are by default supplied with scaled versions of these arguments. "


You can find examples under PolarPlot > Examples > Options >
ColorFunction.

Brett Champion
Wolfram Research

Murray Eisenberg

unread,
Dec 26, 2007, 5:11:56 AM12/26/07
to
My fault: I didn't find what I was looking for about ColorFunction with
PolarPlot on the ColorFunction reference page, and I failed to seek it
on the PolarPlot page.

But this would probably not have happened had PolarPlot also been
mentioned on that ColorFunction page. (Or did I overlook it there?)

Brett Champion

unread,
Dec 27, 2007, 3:43:46 AM12/27/07
to
On Dec 26, 2007, at 4:09 AM , Murray Eisenberg wrote:

> My fault: I didn't find what I was looking for about ColorFunction
> with
> PolarPlot on the ColorFunction reference page, and I failed to seek it
> on the PolarPlot page.
>
> But this would probably not have happened had PolarPlot also been
> mentioned on that ColorFunction page. (Or did I overlook it there?)
>

No, PolarPlot and a few other functions are missing from the table on
the ColorFunction page. For XXXXPlot documentation, I generally
suggest looking at the documentation for the function first, instead
of the options. The function documentation should have fairly
complete coverage of how the options can be used in ways specific to
that function, but the documentation for the options frequently just
samples the functions that have that option.

(An exception to this is that general graphics options like
AspectRatio or Background that don't have any special behavior for a
function generally aren't covered in any detail, if at all.)

Brett Champion
Wolfram Research

0 new messages