michael watson (IAH-C)
2004-Dec-21 11:05 UTC
[R] Creating a vector of colours that are as different from one another as possible
Hi I want to create a vector of colors that are as different from one another as possible. ?rainbow states "Conceptually, all of these functions actually use (parts of) a line cut out of the 3-dimensional color space...". This suggests to me that the resulting colors are all placed on this "line" and are equi-distant along it. The resulting color palette is a range of colours where adjacent colours are actually quite similar, especially when n (the number of colours) is high. Conceptually I guess what I want is colors from a 3D polygon in 3D colour space, where the number of vertices in the polygon is n, resulting in a color palette where the colors are all quite different from one another. Is this possible or am I talking crap? (I've only had one coffee this morning) Thanks in advance Mick
(Ted Harding)
2004-Dec-21 13:02 UTC
[R] Creating a vector of colours that are as different from
On 21-Dec-04 michael watson \(IAH-C\) wrote:> Hi > > I want to create a vector of colors that are as different > from one another as possible. ?rainbow states "Conceptually, > all of these functions actually use (parts of) a line cut out > of the 3-dimensional color space...". This suggests to me > that the resulting colors are all placed on this "line" and > are equi-distant along it. The resulting color palette is > a range of colours where adjacent colours are actually quite > similar, especially when n (the number of colours) is high. > > Conceptually I guess what I want is colors from a 3D polygon > in 3D colour space, where the number of vertices in the polygon > is n, resulting in a color palette where the colors are all > quite different from one another. Is this possible or am I > talking crap? (I've only had one coffee this morning)One is not enough, by a long way, in my experience ... How large is n? It's not easy to select more than a few clearly distinct colours. Also, "distinct" is context-dependent, because: What will be the spatial relationships of the different colours in your output? You can successfully have fairly similar colours adjacent to each other, since the contrast is more obvious when they're adjacent. However, if you want to use colours to track identity and difference across scttered points or patches, then you need bigger separations between colours, since you want to be able to see easily that patch "A" here is of the same kind as patch "A" there and different from patch "B" somwehere else, when mingled with patches of other kinds. And size matters. Big patches of similar colour (as on a map) can look quite distinct, while the same colours used to plot filled circular blobs on a graph might be barely distinguishable, and totally undistinguishable if used to plot coloured "."s or "+"s. It depends too on what you will be using to render the colours. Monitor screens vary in their aility to render different colours distinctly, and so do colour printers. It's all very psycho-visual and success usually requires experimentation! Cheers, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 21-Dec-04 Time: 13:02:10 ------------------------------ XFMail ------------------------------
Petr Pikal
2004-Dec-21 13:37 UTC
[R] Creating a vector of colours that are as different from one another as possible
On 21 Dec 2004 at 11:05, michael watson (IAH-C) wrote:> Hi > > I want to create a vector of colors that are as different from one > another as possible. ?rainbow states "Conceptually, all of these > functions actually use (parts of) a line cut out of the 3-dimensional > color space...". This suggests to me that the resulting colors are > all placed on this "line" and are equi-distant along it. The > resulting color palette is a range of colours where adjacent colours > are actually quite similar, especially when n (the number of colours) > is high. > > Conceptually I guess what I want is colors from a 3D polygon in 3D > colour space, where the number of vertices in the polygon is n, > resulting in a color palette where the colors are all quite different > from one another. Is this possible or am I talking crap? (I've only > had one coffee this morning)Hi Micheal With increased number of colors you always end with neighbour colors quite similar. If I understand the rainbow function correctly it sets saturation to 1 (maximum) value to 1 (maximum) and divide the third component hue to equally spaced intervals to get the most different colours from given range of hues. You can also experiment with hsv() function> plot(1:11, col = hsv(h = seq(0,1,.1), s=1, v=0)) #all black > plot(1:11, col = hsv(h = seq(0,1,.1), s=1, v=1)) # different coloursYou can imagine hue as a circle from 0 to 360 and if you want to have neighbouring colours to be the most different you have to choose them from oposit parts of a circle e.g. 0,180 or 90,270. So barvy<-rainbow(12) vyber<-c(1,7,3,9,5,11,2,8,4,10,6,12) plot(1:12,col=rainbow(12)[vyber]) will give you a sequence of 12 colours which are by my opinion most different. Cheers Petr> > Thanks in advance > Mick > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
Thomas Lumley
2004-Dec-21 16:04 UTC
[R] Creating a vector of colours that are as different from one another as possible
On Tue, 21 Dec 2004, michael watson (IAH-C) wrote:> > Conceptually I guess what I want is colors from a 3D polygon in 3D > colour space, where the number of vertices in the polygon is n, > resulting in a color palette where the colors are all quite different > from one another. Is this possible or am I talking crap? (I've only had > one coffee this morning) >It depends on whether you need the colors to be different colors or whether lightness and saturation differences are ok. For example, a cube with edges parallel to the axes in RGB space will have quite strong lightness differences, and will probably have visible saturation differences (depending on exactly which cube it is). Often this is a Bad Thing. It's hard to get a large number of colours that are all obviously different. The ColorBrewer palettes (which are optimised for map coloring) go up to 11, but some of these are sets of light/dark pairs. If you wanted small plotting symbols it would be even more difficult, since blue-yellow distinctions are less visible in small things and since you probably want higher saturation. -thomas -thomas
Ross Ihaka
2004-Dec-22 19:04 UTC
[R] Creating a vector of colours that are as different from one another as possible
michael watson (IAH-C) wrote:> Hi > > I want to create a vector of colors that are as different from one > another as possible. ?rainbow states "Conceptually, all of these > functions actually use (parts of) a line cut out of the 3-dimensional > color space...". This suggests to me that the resulting colors are all > placed on this "line" and are equi-distant along it. The resulting > color palette is a range of colours where adjacent colours are actually > quite similar, especially when n (the number of colours) is high. > > Conceptually I guess what I want is colors from a 3D polygon in 3D > colour space, where the number of vertices in the polygon is n, > resulting in a color palette where the colors are all quite different > from one another. Is this possible or am I talking crap? (I've only had > one coffee this morning)First, you want to be using a color space where distance corresponds to perception of similarity/difference. There are a number of perceptually based spaces which approximate this (CIELUV, CIELAB and Munsell). You could put your points in one of these spaces and them move them about until they are as far from each other as possible. Second, it's generally considered bad practice to use more that six colors in a single display. Given the approximate nature of the uniformity of the perceptual color spaces you could consider placing this many points "by hand." How much sense this makes depends on what it is you are trying to do. (I found reading some of what Munsell had to say pretty informative.) -- Ross Ihaka Email: ihaka at stat.auckland.ac.nz Department of Statistics Phone: (64-9) 373-7599 x 85054 University of Auckland Fax: (64-9) 373-7018 Private Bag 92019, Auckland New Zealand