====== Colors in R ====== ===== Colors in R ===== We get the list of all named colors in R using the command > help(colors) > colors() A colored [[http://research.stowers-institute.org/efg/R/Color/Chart/|list of colors]] is available on the WWW. The basic commands for dealing with colors are extended by the package [[http://cran.r-project.org/web/packages/colorspace/colorspace.pdf|colorspace]]. Different color definitions can be found at http://colors.bravo9.com/ , http://en.wikipedia.org/wiki/List_of_colors and sites of color producers such as [[http://www.crayola.com/colorcensus/history/current_120_colors.cfm|Crayola]] ([[http://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors|colors]]) or [[https://www.carandache.com/ch/en/|Caran d'Ache]] ([[http://www.carandache.ch/filedownload.lbl?url=/CDA08/Files/FA/Artistes%20et%20Professionnels/Pastels/Neoart/Nuancier_Neoart_Eng.pdf|colors]]), [[https://www.pantone.com/|Pantone]]. Some conversions > rgb(255, 255, 0, maxColorValue=255) [1] "#FFFF00" > col2rgb('red') [,1] red 255 green 0 blue 0 > col2rgb("#D55E00") [,1] red 213 green 94 blue 0 ===== Palettes of distinct colors for nominal data ===== Suppose that we produced a clustering of given territorial units. We would like to display it on the corresponding map so that the units belonging to different clusters can be easily seen. This leads to a problem of constructing of a palette of colors as distinct as possible. The standard solution in R is provided by [[http://cran.r-project.org/web/packages/RColorBrewer/RColorBrewer.pdf|RColorBrewer]] > library(RColorBrewer) > display.brewer.all(type="qual") {{notes:pics:rcbqual.png}} Ware recommends the six opponent-channel colors (red, green, yellow, blue, black, white) followed by six other distinct colors (pink, cyan, gray, orange, brown, and purple). But which palette to use if the number of clusters is over 12 ? The rainbow colors are too similar. > library(graphics) > par(mar=c(1,1,1,0)+0.1) > ware <- c("red","green","yellow","blue","black","white","pink","cyan","gray","orange","brown","purple") > pie(rep(1,12), col=ware) > pie(rep(1,24), col=rainbow(24)) {{notes:pics:ware.png?360}} {{notes:pics:rainbow24.png?360}} ===== Alphabet colors ===== An interesting solution for up to 26 colors was proposed by Paul Green-Armytage in his paper [[http://eleanormaclure.files.wordpress.com/2011/03/colour-coding.pdf|A Colour Alphabet and the Limits of Colour Coding]]. His solution was inspired by the palette of 22 distinct colors proposed in 1965 by Kenneth Kelly. {{notes:pics:palette8.png?720}} The initial color alphabet was {{notes:pics:palette10.png?720}} and its revised final version {{notes:pics:palette12.png?720}} The final version has the property that the corresponding letter is also the first letter in the color's name. alphabet <- c( rgb(255,204,153,maxColorValue=255,names="Honeydew"), rgb(148,255,181,maxColorValue=255,names="Jade"), rgb( 94,241,242,maxColorValue=255,names="Sky"), rgb(224,255,102,maxColorValue=255,names="Uranium"), rgb(255,255,128,maxColorValue=255,names="Xanthin"), rgb(240,160,255,maxColorValue=255,names="Amethyst"), rgb(255,225, 0,maxColorValue=255,names="Yellow"), rgb(255,168,187,maxColorValue=255,names="Pink"), rgb(157,204, 0,maxColorValue=255,names="Lime"), rgb(255,164, 5,maxColorValue=255,names="Orpiment"), rgb( 43,206, 72,maxColorValue=255,names="Green"), rgb(194, 0,136,maxColorValue=255,names="Mallow"), rgb(255, 0, 16,maxColorValue=255,names="Red"), rgb( 0,153,143,maxColorValue=255,names="Turquoise"), rgb(116, 10,255,maxColorValue=255,names="Violet"), rgb(255, 80, 5,maxColorValue=255,names="Zinnia"), rgb( 0,117,220,maxColorValue=255,names="Blue"), rgb(128,128,128,maxColorValue=255,names="Iron"), rgb(153, 63, 0,maxColorValue=255,names="Caramel"), rgb(143,124, 0,maxColorValue=255,names="Khaki"), rgb( 66,102, 0,maxColorValue=255,names="Quagmire"), rgb(153, 0, 0,maxColorValue=255,names="Wine"), rgb( 0, 92, 49,maxColorValue=255,names="Forest"), rgb( 0, 51,128,maxColorValue=255,names="Navy"), rgb( 76, 0, 92,maxColorValue=255,names="Damson"), rgb( 25, 25, 25,maxColorValue=255,names="Ebony"), rgb(255,255,255,maxColorValue=255,names="White")) > n <- length(alphabet) > pie(rep(1,n),col=alphabet) {{notes:pics:alphabet.png?360}} ===== Optimization approach ===== [[http://www.bioss.ac.uk/staff/chris.html|Chris Glasbey]] with his collaborators proposed in their paper [[http://www.bioss.ac.uk/staff/chris/colorpaper.pdf|Colour displays for categorical images]] an optimization approach to determine a palette with most distinct colors. Similar approach was presented also in http://www.ics.uci.edu/~goodrich/pubs/color.pdf . ===== URLs ===== ==== Palettes ==== * http://www.anychart.com/products/anychart/docs/users-guide/Palettes.html * http://en.wikipedia.org/wiki/List_of_color_palettes * http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors * http://web.media.mit.edu/~wad/color/palette.html * http://eleanormaclure.files.wordpress.com/2011/03/colour-coding.pdf * http://designfestival.com/creating-a-color-palette/ * http://www.1stwebdesigner.com/freebies/15-useful-color-mixers-for-effective-designing/ * http://www.anychart.com/products/anychart/docs/users-guide/map-visualisation.html * http://modernl.com/article/web-2.0-colour-palette * http://blogs.sas.com/jmp/index.php?/authors/7-Xan-Gregg/P3.html * http://books.google.com/books?id=zzCiSJoohuQC&pg=PA599&lpg=PA599&dq=distinct+color+palette+data+visualization&source=bl&ots=hvFBNaTfh1&sig=nfMCuQca3-7B4KxCBaHL5jlNOtk&hl=en&ei=WcxGTtGALo_VsgaRkuSzBw&sa=X&oi=book_result&ct=result&resnum=9&sqi=2&ved=0CFwQ6AEwCA#v=onepage&q&f=false * http://www.jeromecukier.net/ * http://www.w3.org/TR/SVG/types.html#ColorKeywords * http://www.jeromecukier.net/blog/2011/08/09/d3-adding-stuff-and-oh-understanding-selections/ * http://mbostock.github.com/d3/ * http://www.research.ibm.com/dx/proceedings/pravda/index.htm * http://www.brucelindbloom.com/ * http://www.karlhartig.com/chart/chart.html * http://www.leebyron.com/what/lastfm/ * http://www.instantshift.com/2011/02/04/effective-color-palette-and-color-scheme-generators/ * http://www.scribd.com/doc/54440349/Visual-Guidebook-Data-Visualization * http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=155 * http://en.wikibooks.org/wiki/R_Programming/Graphics * http://www.jstatsoft.org/v24 * http://www.mostlycolor.ch/2011/06/aic-study-group-on-language-of-color-lc.html * http://colornaming.net/ * http://people.csail.mit.edu/jaffer/Color/Dictionaries * http://www.icsi.berkeley.edu/wcs/data.html ; http://www.icsi.berkeley.edu/~kay/ * http://www.graphviz.org/doc/info/colors.html * http://cloford.com/resources/colours/500col.htm * http://web.njit.edu/~kevin/rgb.txt.html * http://answers.oreilly.com/topic/453-color-names-and-rgb-values-with-wide-browser-support/ * http://www.pnas.org/content/103/44/16608.abstract ==== Color names ==== * http://www.20000-names.com/color_names.htm * http://en.wikipedia.org/wiki/Linguistic_relativity_and_the_color_naming_debate * http://www.europa-pages.com/lessons/spanish-colors.html * http://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors * http://www.toptenz.net/top-10-weird-colors.php * http://www.efg2.com/Lab/Library/Color/ ===== To do ===== ==== Clustering ==== !!!! Poskusi razvrščati http://colors.bravo9.com/ http://colors.bravo9.com/nbs-iscc-p-plochere-color-system/ http://colors.bravo9.com/nbs-iscc-p-plochere-color-system/list/all/ ==== Optimization ==== 14.8.2011 Problem: ali se da narediti boljšo optimizacijo? Colour displays for categorical images http://www.bioss.ac.uk/staff/chris.html http://www.bioss.ac.uk/staff/chris/colorpaper.pdf http://www.ics.uci.edu/~goodrich/pubs/color.pdf http://eleanormaclure.files.wordpress.com/2011/03/colour-coding.pdf http://cran.r-project.org/web/packages/colorspace/colorspace.pdf pretvorba RGB -> LAB ===== Colors ===== > relc <- c("lightpink","yellow","orange","olivedrab3","steelblue3","lightskyblue1", + "darkorchid","tomato","bisque3","springgreen3","darkgoldenrod","gray75") > library(graphics) > par(mar=c(1,1,1,0)+0.1) > pie(rep(1,12), col=relc) > relc <- c("lightpink","yellow","orange","olivedrab4","steelblue3","lightskyblue1", + "darkorchid","firebrick1","chartreuse","springgreen3","darkgoldenrod","gray75") > pie(rep(1,12), col=relc) {{notes:pics:colorRel.png?360}} {{notes:pics:color12.png?360}} ===== Colors 2 ===== Colors from http://gjabel.wordpress.com/2014/03/28/circular-migration-flow-plots-in-r/ : > d <- c( + 255,0,0 , + 210,150,12 , + 125,175,0 , + 117,0,255 , + 160,0,125 , + 29,100,255 , + 0,255,233 , + 73,255,100 , + 100,146,125, + 255,219,0 ) > D <- matrix(d,ncol=3,byrow=TRUE) > cd <- rgb(D,maxColorValue=255) > pie(rep(1,10), col=cd) > cb <- c( "#FF0000C8", "#D2960CC8", "#7DAF00C8", "#7500FFC8", "#A0007DC8", + "#1D64FFC8", "#00FFE9C8", "#49FF64C8", "#64927DC8", "#FFDB00C8" ) > pie(rep(1,10), col=cb) ===== His/Her colors ===== * http://www.datapointed.net/media/2012/09/colors.txt * http://www.datapointed.net/visualizations/color/men-women-color-names-d3/ * http://www.datapointed.net/2012/09/his-and-hers-colors-d3-svg/ *http://infosthetics.com/archives/2012/09/his_and_hers_colors_popular_color_names_by_gender_preference.html * http://www.datapointed.net/2010/09/men-women-color-names/ * http://blag.xkcd.com/2010/05/03/color-survey-results/ * http://xkcd.com/color/rgb/ * http://blog.xkcd.com/2010/05/03/color-survey-results/ * http://en.wikipedia.org/wiki/X11_color_names Sestavi graf najbližjih sosedov ali r-okolic za http://xkcd.com/color/rgb/. Določi skupine. ===== URLs ===== - https://bookdown.org/hneth/ds4psy/D-3-apx-colors-basics.html - https://cran.r-project.org/web/packages/unikn/vignettes/colors.html - https://www.stat.auckland.ac.nz/~ihaka/downloads/R-colours-a4.pdf - https://greggilbertlab.sites.ucsc.edu/teaching/rtransition/ - https://github.com/EmilHvitfeldt/r-color-palettes - https://emilhvitfeldt.github.io/r-color-palettes/discrete.html - https://gt.rstudio.com/reference/data_color.html - https://www.color-meanings.com/colors-that-start-with-r/