如何在R?中使用Matlab内置配色方案?

时间:2014-04-20 22:00:02

标签: r matlab color-scheme

我正在研究R中的图像处理。目前我正在使用默认的配色方案(topo,terrain,rainbow,heat,cm)。但是,我想使用Matlab提供的配色方案(特别是黑色到黄色配色方案 - 热)和R.有没有办法在R中使用这些配色方案?我使用了OOMPA软件包,其中包含用于生物图像的R的其他颜色方案(http://bioinformatics.mdanderson.org/Software/OOMPA/ClassDiscovery/html/colorSchemes.html),但这并没有解决目的。

Matlab color scheme http://www.mathworks.de/help/matlab/ref/colormap-dropdown.gif

2 个答案:

答案 0 :(得分:6)

install.packages("dcemriS4", dependencies=TRUE)
library(dcemriS4)
hotmetal(10) 
image(outer(1:20,1:20,"+"), col=hotmetal(75), main="hotmetal")

enter image description here

为了教新手“如何捕鱼”,我会承认我事先并不知道这一点,我所做的是:

install.packages("sos") # which I consider to essential in ones R tool chest of search strategies 
library(sos) # actually it's in my .Rprofile
findFn("color matlab hot")

找到了dcemri http://finzi.psych.upenn.edu/R/library/dcemri/html/hotmetal.html

我只在当前包中找到了library(dcemriS4),所以我加载了它并在旧版程序包帮助页面中使用代码进行了一次拍摄......成功。

答案 1 :(得分:4)

?colorRampPalette

plot(1:20, pch = 19, cex = 5, 
     col = colorRampPalette(c('black','red','yellow','white'))(20))

enter image description here

相关问题