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

3
我正在使用R进行图像处理。目前,我正在使用默认的颜色方案(topo、terrain、rainbow、heat、cm)。但是,我想在R中使用Matlab提供的颜色方案(特别是黑色到黄色的颜色方案-Hot)。是否有办法在R中使用这些颜色方案?我使用了OOMPA包,该包包括用于生物图像的其他颜色方案(http://bioinformatics.mdanderson.org/Software/OOMPA/ClassDiscovery/html/colorSchemes.html),但这并没有解决问题。 Matlab color scheme (来源:mathworks.de

请参考?colorRampPalette以了解构建这些的一般方法。Jet在示例中。 - mdsumner
2个回答

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),所以我加载了它,并尝试了旧软件包帮助页面中的代码... 成功了。


4
?colorRampPalette

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

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接