3
$\begingroup$

I want to use Filling for ListPolarPlot in such a way that the points in the list are joined to the origin with a line colored same as in the Filling -> Axis of ListPlot.

I could do it up to a certain stage, but I couldn't set the color of the lines. Here is what I have done.

Suppose that

pl = Table[{k, Sin[k]}, {k, 0, 10}]

is the point list. I can connect them to the origin in a tricky way by

Show[Table[ListPolarPlot[{{0, 0}, pl[[k]]}, Joined->True], {k,1,Length[pl]}],
     ListPolarPlot[pl]]

but I can not set the color of the joining lines as the following code would do.

ListPlot[pl, Filling -> Axis]

I would be very glad if someone would tell me how to color the lines.

$\endgroup$
4
  • $\begingroup$ Have you tried PlotStyle? $\endgroup$
    – E.O.
    Dec 17, 2012 at 13:02
  • $\begingroup$ Does adding PlotStyle -> Directive[Hue[0.67, 0.6, 0.6], Opacity[0.2]] after Joined->True in your code give what you need? $\endgroup$
    – kglr
    Dec 17, 2012 at 13:05
  • $\begingroup$ you can get the specific color directives used in ListPlot[pl,Filling-Axis] using Normal[ListPlot[pl,Filling->Axis][[1]]]. $\endgroup$
    – kglr
    Dec 17, 2012 at 13:10
  • 1
    $\begingroup$ Thank you very much E.O. and kguler. I found in the examples of Mathematica PlotStyle->ColorFunction[1,"ColorData"] but could not find the right color. It seems that I had to change the Opacity. $\endgroup$
    – bkarpuz
    Dec 17, 2012 at 13:11

2 Answers 2

2
$\begingroup$

How about

pl = Table[{k, Sin[k]}, {k, 0, 10}];

Show[
    ListPolarPlot[{{0, 0}, #} & /@ pl,PlotStyle -> Directive[Thin, Green], Joined -> True], 
    ListPolarPlot[pl]
]

Where you can change Directive[Thin, Green] to whatever color is appropriate (the specifications in kguler's comment are probably what you are looking for)

$\endgroup$
2
$\begingroup$

You can draw a Line from origin to each point

Show[
  ListPolarPlot[pl],
  Graphics[{
    Thin,Green,
    Line[{{0,0},#[[2]]{Cos[#[[1]]],Sin[#[[1]]]}}&/@pl]
  }]
]

output

Here's a function that takes a plot as first argument and adds lines from origin styled with following arguments:

fill[lpp_,spec___:Blue]:=Show[
  lpp,
  Graphics[{
    Thin,spec,
    Line[{{0,0},#}&/@lpp[[1,3,1]]]
   }]
 ]

lpp=ListPolarPlot[pl];
fill[lpp,Red,Dashed]

reddashed

$\endgroup$

Your Answer

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

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