即使代码显示了不同的颜色,我的系统发育树仍然保持着彩虹色

时间:2019-03-16 19:48:26

标签: r colors phylogeny

我正在使用猿,地图和植物工具在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()

使用此代码时,我得到以下图像:

when I use this code I get the follow image

有人知道为什么会这样做吗?

1 个答案:

答案 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)