Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
Have you tried PlotStyle? –  E.O. Dec 17 '12 at 13:02
    
Does adding PlotStyle -> Directive[Hue[0.67, 0.6, 0.6], Opacity[0.2]] after Joined->True in your code give what you need? –  kguler Dec 17 '12 at 13:05
    
you can get the specific color directives used in ListPlot[pl,Filling-Axis] using Normal[ListPlot[pl,Filling->Axis][[1]]]. –  kguler Dec 17 '12 at 13:10
1  
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. –  bkarpuz Dec 17 '12 at 13:11
add comment

2 Answers 2

up vote 2 down vote accepted

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)

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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