[R] Help on drawing stars and radars in R (update)

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Jun 11 11:45:01 CEST 2009


On Thu, Jun 11, 2009 at 10:01 AM, Caroline
Gideon-Adeniyi<c.gideon-adeniyi1 at fashion.arts.ac.uk> wrote:
> Hi
>
> I don't know if you can help. I am a 2nd year Bsc Cosmetic Science student and in R I need some help in drawing stars.
>
> The problem that I have is I want to recreate a radar diagram similar to the one in excel.
>
> I have put in these commands in a script window:
>
>  stars(shampoo1[, 1:6], locations = c(0,0), radius = TRUE,
>  key.loc=c(0,0),
>  main = "Ranked Results for the Sensory Evaluation of the Shampoo" ,
>  frame.plot = TRUE,
>  key.labels = c("Foam Texture", "Skin Feel", "Rinsability", "Wet Combability", "Wet Feel", "Odour"),
>  lty = 2,
> )
>
> This gives me a black and white radar which is fine.
>
> Now according to the reference manual to colour the stars i need to add:
>
> col.stars = rainbow (30)
>
> Which colours in each star segment. The problem I have with this is that the segments are filled with colour and the segments overlap each other and each segment is not visible.
>
> So I desperately need the command that only colours the outline of the segments or stars instead of  filling it.
>
> This is the example given in the reference manual:
>
> stars(mtcars[, 1:7], locations = c(0,0), radius = FALSE,
> key.loc=c(0,0), main="Motor Trend Cars", lty = 2)
>
>
> Can u help?

 The stars are drawn using R's polygon function, and that has two
colours - the fill colour and the border colour. It seems that the
stars function only lets you set the fill colour and not the border
colour which is what you want.

 It is possible to modify the stars function to also set the border
colour, but that can be a bit beyond beginners skills. I reckon
someone on this list will come up with a modified stars() function
before the end of the day that does it. It might be me, if it wasn't
for the fact I have other things I should be doing!

 All that needs doing is to add a col.border argument to stars, and
then make sure border= is used when stars calls polygon. I've half
done it already.

 Is this the first use of R in cosmetic science? Maybe next time I see
a shampoo advert on TV and they do the 'here comes the science' bit,
we'll see a plot made in R...

 Barry




More information about the R-help mailing list