Hello I'm using rainbow function to generate 10 colors for the plot and it is difficult to tell the neighboring colors from each other. How can I make the colors more differently. Thanks Zhaoming [[alternative HTML version deleted]]
Specify them exactly if there are only 10. On Jan 6, 2008 10:55 PM, Wang, Zhaoming (NIH/NCI) [C] <wangzha at mail.nih.gov> wrote:> Hello > I'm using rainbow function to generate 10 colors for the plot and it is > difficult to tell the neighboring colors from each other. How can I make > the colors more differently. > > Thanks > Zhaoming > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
> I'm using rainbow function to generate 10 colors for the plot and it is > difficult to tell the neighboring colors from each other. How can I make > the colors more differently.Using 10 colours is always going to be difficult, but take a look at ColorBrewer (http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer.html), and the associated R package RColorBrewer. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
Wang, Zhaoming (NIH/NCI) [C] wrote:> Hello > I'm using rainbow function to generate 10 colors for the plot and it is > difficult to tell the neighboring colors from each other. How can I make > the colors more differently. >If all you want is for neighbouring colours to be distinguishable you could just sample(rainbow(10)) until you get a palette with neighbouringly distinguishable colours: # some neighbours look similar: plot(1:10, col=rainbow(10)) # so try this: set.seed(1) # so your random numbers are the same as mine... p = sample(rainbow(10)) plot(1:10, col=p) # hmmm green and cyan are still next to each other. Lets try again: p=sample(rainbow(10)) plot(1:10,col=p) - and repeat until you are happy with the sequence. Then use the same palette in your legend. This is fine for simple plots where coloured objects are discrete, such as in a bar chart, but perhaps wouldn't work for overlapping coloured objects, like several time series together or several scatterplots. Perhaps use 5 colours and two point types for points, or two line styles for lines, or two fill styles for areas. rainbow() is great - for drawing rainbows - but the palettes from the RColorBrewer package are much better for statistical plots as someone else suggested. When I write code for plots I try and use RColorBrewer if it's there: getColours <- function(nv=4){ if(require(RColorBrewer)){ cols=brewer.pal(nv,"Pastel1") }else{ warning("This plot would like nicer if you installed RColorBrewer") cols=(1:nv) } return(cols) } Barry
If your main goal is to find 10 colors that are easy to tell apart and look good in a graph, then look at the RColorBrewer package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Wang, > Zhaoming (NIH/NCI) [C] > Sent: Sunday, January 06, 2008 8:56 PM > To: r-help > Subject: [R] rainbow function > > Hello > I'm using rainbow function to generate 10 colors for the plot > and it is difficult to tell the neighboring colors from each > other. How can I make the colors more differently. > > Thanks > Zhaoming > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
hello: I am trying to use R to draw a 3D picture, then color the picture according to the value of z , how could I do this job? this is my exalple x<-y<-seq(-50,50,2) m<-function(x,y) x^3+y^3-x^2*y-x*y^2 z<-outer(x,y,m) persp(x,y,z,theta=-60,phi=30) I want to draw the Zmax in red and Zmin in blue, the value between Zmax and Zmin is colored gradually thank you very much [[alternative HTML version deleted]]
On Jan 2, 2012, at 1:31 AM, ?? wrote:> hello: > I am trying to use R to draw a 3D picture, then color the picture > according to the value of z , how could I do this job? > this is my exalple > > x<-y<-seq(-50,50,2) > m<-function(x,y) x^3+y^3-x^2*y-x*y^2 > z<-outer(x,y,m) > persp(x,y,z,theta=-60,phi=30) > > I want to draw the Zmax in red and Zmin in blue, the value between > Zmax and Zmin is colored graduallyHave you looked at the help(persp) example # 4?> thank you very much > [[alternative HTML version deleted]]> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html-- David Winsemius, MD West Hartford, CT
Seasonal Greetings! I am trying to plot a simple survival curve using; plot(survfit(Surv(d01,cens) ,conf.type="none" ),xlab="Time",ylab="Survival") I would be interested in a percentage scale on the y-axis. How do I achieve sucha scale? Thank you in advance!