热图中的scale_color_gradient2
我正在绘制系统发育树并使用 gheatmap() 添加热图。 我想使用低点、中点和高点更改颜色比例尺。 我认为scale_color_gradient2()使这成为可能,但它不起作用。
p <- ggtree(tree.c$scenario.1, layout='fan',branch.length = "none",
options(ignore.negative.edge=TRUE))
plot(p)
group <- as.matrix(fit0[,7])
rownames(group)<-tree.c$scenario.1$tip.label
colnames(group)<-c("Temperature")
library(ggnewscale)
p2 <- p + new_scale_fill()
gheatmap(p2, group, offset=1, width=.2,
colnames= F, colnames_offset_y = .2) +
scale_color_gradient2( low = "blue", mid = "white", high = "red") +
theme(legend.key.size = unit(5, 'cm'),
legend.text=element_text(size=20),
plot.title = element_text(size=100, hjust = 0.5, vjust = 1.5))
但它显示错误“‘y’的比例已经存在。为‘y’添加另一个比例,这将取代现有的比例。热图”并且未应用低、中(中点 = 0)和高颜色。它是如何固定的或者如何设置中点颜色渐变?
提前致谢!
I am drawing phylogenetic tree and added heatmap with gheatmap().
I would like to change color scale bar using low, mid, and high point.
I thought scale_color_gradient2() made that possible, but it doesn't work.
p <- ggtree(tree.c$scenario.1, layout='fan',branch.length = "none",
options(ignore.negative.edge=TRUE))
plot(p)
group <- as.matrix(fit0[,7])
rownames(group)<-tree.c$scenario.1$tip.label
colnames(group)<-c("Temperature")
library(ggnewscale)
p2 <- p + new_scale_fill()
gheatmap(p2, group, offset=1, width=.2,
colnames= F, colnames_offset_y = .2) +
scale_color_gradient2( low = "blue", mid = "white", high = "red") +
theme(legend.key.size = unit(5, 'cm'),
legend.text=element_text(size=20),
plot.title = element_text(size=100, hjust = 0.5, vjust = 1.5))
But it showed the error "scale for 'y' is already present. adding another scale for 'y', which will replace the existing scale. heatmap" And low, mid (midpoint = 0), and high color were not applied. How is it fixed or how do I set the color gradient with midpoint?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论