search for: codecol

Displaying 1 result from an estimated 1 matches for "codecol".

2012 Jul 17
2
aligning image with bar plot in the same plot
...djusting bottom and up par it lines up ## mar1 <- c(1.9,0,1.9,2) ## par(mar=mar1) colorsBarPlot <- c(rep('green', 100), rep('blue', 100), rep('black', 100)) barplot(rep(1, 300), space=0, border=NA, col=colorsBarPlot, horiz=T, axes=F) # it works but seems to cumbersome codeCol <- as.numeric(as.factor(colorsBarPlot)) colsImage <- unique(colorsBarPlot) colsBreaks <- sort(unique(c(codeCol-0.5, codeCol+0.5))) image(matrix(codeCol, nrow=1), col=rev(colsImage), breaks=colsBreaks, axes=F) ######### end of code [[alternative HTML version deleted]]