我正在使用猿,地图和植物工具在R中构建系统发育树,但是成功了,无论我将其更改为哪种颜色,都将其保留为彩虹调色板着色。
jpeg("branch3.jpg", width = 1000, height = 1000)
plotBranchbyTrait(tree2, x.num, type = "fan",
mode = c("edges","tips","nodes"),
col = c("midnightblue", "deepskyblue", "turquoise1",
"seagreen1", "springgreen3"),
legend = TRUE, xlims = NULL, cex = 1.5, lwd = 0.5)
dev.off()
使用此代码时,我得到以下图像:
有人知道为什么会这样做吗?
答案 0 :(得分:2)
提供给plotBrancbyTrait
的颜色通过palette
参数传递(请参见功能手册)。您可以使用colorRampPalette
函数创建一个调色板。例如,在您的情况下:
## Creating a customised palette
my_palette <- colorRampPalette(c("midnightblue", "deepskyblue", "turquoise1", "seagreen1", "springgreen3"))
然后可以按如下所示将其正常传递给plotBranchbyTrait
函数:
## Plotting branch colors with a personalised palette
plotBranchbyTrait(tree2, x.num, type = "fan",
mode = c("edges","tips","nodes"),
palette = my_palette,
legend = TRUE, xlims = NULL, cex = 1.5, lwd = 0.5)