2
$\begingroup$

I am trying to plot a set of concentric green dashed circles and a green ray.

I was able to produce the desired result using ContourPlot

  b = Range[4, 10, 2]; 

Animate[Show[
      ContourPlot[{x^2 + y^2 == b^2, y = a x}, {x, -10, 10}, {y, -10, 10},
        Axes -> True, 
       ContourStyle -> {Directive[Lighter[Green], Dashed], Darker[Green]},
        PerformanceGoal -> "Quality"], 
      ParametricPlot[{a Cos[\[Theta]], a Sin[\[Theta]]}, {a, 0, 10}, 
       PlotStyle -> Darker@Green]], {\[Theta], 0, 2 \[Pi], 0.01}]

but then I read on the wolfram guide that I should use ParametricPlot to plot the curves so I tried using it but no matter what i do PlotStyle does not change the color of the circles

b = Range[4, 10, 2]
{4, 6, 8, 10}
ParametricPlot[{{# Cos[\[Theta]], # Sin[\[Theta]]} & /@ b, {f Cos[0], 
   f Sin[0]}}, {\[Theta], 0, 2 \[Pi]}, {f, 0, 10}, PlotStyle -> Green,
  Axes -> False]

mathematica keeps plotting them blue

what can i do to fix this behavior?

$\endgroup$
2
  • $\begingroup$ You don't really need ParametricPlot[] for this simple case: Graphics[{Green, Circle[{0, 0}, #] & /@ Range[4, 10, 2], Line[{{0, 0}, {10, 0}}]}] $\endgroup$ Jan 15, 2017 at 19:11
  • $\begingroup$ yes you are right but i had never used parametricplot before so i thought to explore this function $\endgroup$
    – Alucard
    Jan 16, 2017 at 8:36

1 Answer 1

2
$\begingroup$

The blue (and gold) you see is the boundary of the (empty) areas plotted. (They are indeed areas, i.e., composed of polygons, because you have two parameters θ and f.) So to color the boundary of the areas, too, use BoundaryStyle -> Green.

ParametricPlot[
 {{# Cos[θ], # Sin[θ]} & /@ b, {f Cos[0], f Sin[0]}},
 {θ, 0, 2 π}, {f, 0, 10}, PlotStyle -> Green, 
 Axes -> False]

Mathematica graphics

ParametricPlot[
 {{# Cos[θ], # Sin[θ]} & /@ b, {f Cos[0], f Sin[0]}},
 {θ, 0, 2 π}, {f, 0, 10}, PlotStyle -> Green, 
 BoundaryStyle -> Green, Axes -> False]

Mathematica graphics

But maybe you want something more like this:

Show[
 ParametricPlot[
  {# Cos[θ], # Sin[θ]} & /@ b,
  {θ, 0, 2 π}, PlotStyle -> Green, Axes -> False],
 ParametricPlot[
  {f Cos[0], f Sin[0]},
  {f, 0, 10}, PlotStyle -> Green]
 ]

Mathematica graphics

I'm not sure why the frame disappears, but if you want it, add the option Frame -> True to either the first plot or to Show[].

Or if you just want this specific figure, you could do it the way @J.M. suggests in a comment above.

$\endgroup$
2
  • $\begingroup$ every once in a while (usually when i don't want to study theory) i make simple gifs with mathematica. it helps me to remember the syntax and the commands. With the figure posted above and a dark background i made a simple animation of a radar, i would like to add the glowing green effect but i think i need to learn more before being able to do this kind of stuff $\endgroup$
    – Alucard
    Jan 16, 2017 at 8:50
  • $\begingroup$ The glowing effect is not easy. See mathematica.stackexchange.com/questions/20855/… for instance. $\endgroup$
    – Michael E2
    Jan 16, 2017 at 11:07

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.