Dear list, The dichromat package defines a dichromat function which "Collapses red-green color distinctions to approximate the effect of the two common forms of red-green colour blindness, protanopia and deuteranopia."
library(dichromat) library(grid) colorStrip <- function (colors = 1:3, draw = TRUE) { x <- seq(0, 1 - 1/length(colors), length = length(colors)) y <- rep(0.5, length(colors)) my.grob <- grid.rect(x = unit(x, "npc"), y = unit(y, "npc"), width = unit(1/length(colors), "npc"), height = unit(1, "npc"), just = "left", hjust = NULL, vjust = NULL, default.units = "npc", name = NULL, gp = gpar(fill = colors, col = colors, draw = draw, vp = NULL)) my.grob } colorStrip(1:3) colorStrip(dichromat(1:3)) Now what would be nice is a function that can edit the colours (col and fill parameters) of an existing grob. dichromatit <- function(x){ .NotYetImplemented() } dichromatit(colorStrip()) It could allow high-level testing for visual perception of lattice and ggplot2 plots, p1 = xyplot(1~1) p2 = qplot(1,1, colour= I("red")) dichromatit(p1) p2 + dichromatit() One approach could be to use only integer codes for colours, and modify the current palette() (works also for base graphics). But this is quite a stringent request for lattice and ggplot2 which define many named colours in their various themes and scales. Therefore I'd like to think of an approach based on a recursive modification of a grob's gpar components. Does this seem doable with some regular expression magic [*]? All the best, baptiste [*]: http://xkcd.com/208/ ______________________________________________ R-help@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.