Ross Culloch
2009-Mar-13 09:20 UTC
[R] Selecting / creating unique colours for behavioural / transitional data
Dear all, This seems like a simple problem but i've searched the help files and tried various options but failed, so apologies in advance for asking what i'm sure is an easy thing to do! In short, I have displayed behavioural data using the TraMineR package such that there is a colour change between the transition of behaviours, however, all the methods that i have used thus far have given me gradual changes in colour such that it is impossible to tell the difference from several of the behaviours. I have looked in the help section here, and looked at various books and help files in R, but most seem intent on gradual changes in colour for heat, terrain, depth, etc - i may not be looking in the correct places, or perhaps i don't know what i'm looking for, exactly. The code below is the closest i can get to colours being not too similar, but it's still hard to tell apart: col <- rainbow(15,start = 0, end = 1, gamma = 0.5) What i ideally want to do is create a palette with random colours that are no where near one another so that i can tell the 15 different behaviours apart - is this possible? If anyone can help i would be most greatful! Best wishes, Ross -- View this message in context: http://www.nabble.com/Selecting---creating-unique-colours-for-behavioural---transitional-data-tp22492438p22492438.html Sent from the R help mailing list archive at Nabble.com.
Kingsford Jones
2009-Mar-13 12:28 UTC
[R] Selecting / creating unique colours for behavioural / transitional data
Try #install.packages('RColorBrewer') example(brewer.pal, pack='RColorBrewer') hth, Kingsford Jones On Fri, Mar 13, 2009 at 3:20 AM, Ross Culloch <ross.culloch at dur.ac.uk> wrote:> > Dear all, > > This seems like a simple problem but i've searched the help files and tried > various options but failed, so apologies in advance for asking what i'm sure > is an easy thing to do! > > In short, I have displayed behavioural data using the TraMineR package such > that there is a colour change between the transition of behaviours, however, > all the methods that i have used thus far have given me gradual changes in > colour such that it is impossible to tell the difference from several of the > behaviours. I have looked in the help section here, and looked at various > books and help files in R, but most seem intent on gradual changes in colour > for heat, terrain, depth, etc - i may not be looking in the correct places, > or perhaps i don't know what i'm looking for, exactly. > > The code below is the closest i can get to colours being not too similar, > but it's still hard to tell apart: > > col <- rainbow(15,start = 0, end = 1, gamma = 0.5) > > What i ideally want to do is create a palette with random colours that are > no where near one another so that i can tell the 15 different behaviours > apart - is this possible? > > If anyone can help i would be most greatful! > > Best wishes, > > Ross > -- > View this message in context: http://www.nabble.com/Selecting---creating-unique-colours-for-behavioural---transitional-data-tp22492438p22492438.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
Olivier Delaigue
2009-Mar-13 12:56 UTC
[R] Selecting / creating unique colours for behavioural / transitional data
> library(colorRamps) > image(matrix(1:150, 10), col = blue2green2red(15))Regards, Olivier Delaigue Ross Culloch wrote:> > Dear all, > > This seems like a simple problem but i've searched the help files and > tried various options but failed, so apologies in advance for asking what > i'm sure is an easy thing to do! > > In short, I have displayed behavioural data using the TraMineR package > such that there is a colour change between the transition of behaviours, > however, all the methods that i have used thus far have given me gradual > changes in colour such that it is impossible to tell the difference from > several of the behaviours. I have looked in the help section here, and > looked at various books and help files in R, but most seem intent on > gradual changes in colour for heat, terrain, depth, etc - i may not be > looking in the correct places, or perhaps i don't know what i'm looking > for, exactly. > > The code below is the closest i can get to colours being not too similar, > but it's still hard to tell apart: > > col <- rainbow(15,start = 0, end = 1, gamma = 0.5) > > What i ideally want to do is create a palette with random colours that are > no where near one another so that i can tell the 15 different behaviours > apart - is this possible? > > If anyone can help i would be most greatful! > > Best wishes, > > Ross >-- View this message in context: http://www.nabble.com/Selecting---creating-unique-colours-for-behavioural---transitional-data-tp22492438p22495842.html Sent from the R help mailing list archive at Nabble.com.
Alexis Gabadinho
2009-Mar-13 16:25 UTC
[R] Selecting / creating unique colours for behavioural / transitional data
Hi Ross, If you really need 15 colors, maybe you can use the Set3 palette provided by RColorBrewer (this is the one used by TraMineR up to 12 states) and add yourself 3 more colors ? For example (you can mix the hexadecimal color numbers from the RColorBrewer palette and real color names in the same vector) : library(RColorBrewer) mycolors <- brewer.pal(12,"Set3") mycolors <- c(mycolors, "blue", "green", "yellow") All the best, Alexis.
Alexis Gabadinho
2009-Mar-13 16:25 UTC
[R] Selecting / creating unique colours for behavioural / transitional data
Hi Ross, If you really need 15 colors, maybe you can use the Set3 palette provided by RColorBrewer (this is the one used by TraMineR up to 12 states) and add yourself 3 more colors ? For example (you can mix the hexadecimal color numbers from the RColorBrewer palette and real color names in the same vector) : library(RColorBrewer) mycolors <- brewer.pal(12,"Set3") mycolors <- c(mycolors, "blue", "green", "yellow") All the best, Alexis.
Ross Culloch
2009-Mar-13 16:45 UTC
[R] Selecting / creating unique colours for behavioural / transitional data
Hi Alexis, In my opinion you are nothing short of genius! That worked a treat, i thought it would be something simple, but i could not find the script or an example anywhere!!! That was a massive help and has salvaged my day! :clap: Thanks very much to everyone else that helped, it was much appreciated! I only hope i can get to a point in R where i can help people solely for the sake of helping them! Cheers, Ross Hi Ross, If you really need 15 colors, maybe you can use the Set3 palette provided by RColorBrewer (this is the one used by TraMineR up to 12 states) and add yourself 3 more colors ? For example (you can mix the hexadecimal color numbers from the RColorBrewer palette and real color names in the same vector) : library(RColorBrewer) mycolors <- brewer.pal(12,"Set3") mycolors <- c(mycolors, "blue", "green", "yellow") All the best, Alexis. -- View this message in context: http://www.nabble.com/Selecting---creating-unique-colours-for-behavioural---transitional-data-tp22492438p22500457.html Sent from the R help mailing list archive at Nabble.com.