You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I want to mark some stars after the tiplab and thereafter add a bar plot. You can see that the bar plot starts from the tip of the tree, but not next after the stars. How should I modify the code to adjust their positions propers?
Also, the bar plot is too short now, which makes the whole figure not so pretty. How to scale up and make the bar plot wider?
Thanks a lot!
The text was updated successfully, but these errors were encountered:
Hi, I want to mark some stars after the tiplab and thereafter add a bar plot. You can see that the bar plot starts from the tip of the tree, but not next after the stars. How should I modify the code to adjust their positions propers?
You can use offset (For example offset = .25) parameter to control the distance between external layers, or tree panel and external layers.
library("ggplot2")
library("ggtree")
library("ggtreeExtra")
#tree
trfile <- system.file("extdata", "tree.nwk", package="ggtreeExtra")
tr <- read.tree(trfile)
numtip <- length(tr$tip.label)
#data
dat2 <- data.frame(ID=tr$tip.label,
Location=c(rep("HK", 50), rep("TW", 36), rep("SX", 30), rep("GD", 48),
rep("HN", 20), rep("AH", 20), rep("FJ", 26)),
Length=abs(rnorm(n=numtip, mean=0.6)),
Group=c(rep("Yes", 200), rep("No", 30)),
Abundance=abs(rnorm(n=numtip, mean=10, sd=0.00000001)))
p <- ggtree(tr) +
geom_tiplab(align=TRUE,fontface="italic",size = 2) +
geom_treescale(x=6, y=0, fontsize=1.2, linesize=0.3)+ hexpand(5)
p + geom_fruit_list(geom_fruit(data=dat2,
geom=geom_star,
mapping=aes(y=ID, fill=Location),
pwidth=0.1,
stat="identity",
orientation="y",
axis.param=list(axis="x", nbreak=4, vjust=2),
position = position_nudge(50)
),
scale_fill_manual(values=c("#D15FEE","#EE6A50","#FFC0CB","#8E8E38","#9ACD32","#006400","#8B4513"))) +
new_scale_fill() +
geom_fruit(data=dat2,
geom=geom_bar,
mapping=aes(y=ID, x=Abundance, fill=Location),
pwidth=0.1,
stat="identity",
orientation="y",
axis.param=list(axis="x", nbreak=4, vjust=2)
)
Hi, I want to mark some stars after the tiplab and thereafter add a bar plot. You can see that the bar plot starts from the tip of the tree, but not next after the stars. How should I modify the code to adjust their positions propers?
Also, the bar plot is too short now, which makes the whole figure not so pretty. How to scale up and make the bar plot wider?
Thanks a lot!
The text was updated successfully, but these errors were encountered: