Description Usage Arguments Value Author(s) Examples
add the layers to the same position out of ggtree.
1 | geom_fruit_list(fruit, ...)
|
fruit |
the layer of geom_fruit. |
..., |
another layers of geom_fruit, or scales. |
ggplot object
Shuangbin Xu and GuangChuang Yu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | library(ggplot2)
library(ggtree)
library(ggstar)
library(ggnewscale)
set.seed(1024)
tr <- rtree(100)
dt <- data.frame(id=tr$tip.label, value=abs(rnorm(100)), group=c(rep("A",50),rep("B",50)))
df <- dt
dtf <- dt
colnames(df)[[3]] <- "group2"
colnames(dtf)[[3]] <- "group3"
p <- ggtree(tr, layout="fan", open.angle=0)
# first circle
p1 <- p +
geom_fruit(
data=dt,
geom=geom_bar,
mapping=aes(y=id, x=value, fill=group),
orientation="y",
stat="identity"
) +
new_scale_fill()
# second circle
fruitlist <- geom_fruit_list(
geom_fruit(
data = df,
geom = geom_bar,
mapping = aes(y=id, x=value, fill=group2),
orientation = "y",
stat = "identity",
addbrink=FALSE
),
scale_fill_manual(values=c("blue", "red")),
new_scale_fill(),
geom_fruit(
data = dt,
geom = geom_star,
mapping = aes(y=id, x=value, fill=group),
size = 2.5,
color = NA,
starstroke = 0
)
)
p2 <- p1 + fruitlist + new_scale_fill()
# third circle
p3 <- p2 +
geom_fruit(
data=dtf,
geom=geom_bar,
mapping = aes(y=id, x=value, fill=group3),
orientation = "y",
stat = "identity"
) +
scale_fill_manual(values=c("#00AED7", "#009E73"))
p3
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.