ggtree
ggtree copied to clipboard
geom_cladelab removing bar causes warning
Hi.
when I try to remove the bar as suggested by https://yulab-smu.top/treedata-book/chapter10.html a warning is emited. Alternatively, setting the barsize to zero also doesn't remove the bar.
> library(ggtree)
> library(ggplot2)
> library(treeio)
>
> set.seed(2015-12-21)
> tree <- rtree(30)
> data <- data.frame(id=c(45, 34),
> annote=c("test clade", "another clade"),
> image=c("7fb9bea8-e758-4986-afb2-95a2c3bf983d",
> "0174801d-15a6-4668-bfe0-4c421fbe51e8"),
> group=c("A", "B"),
> offset=c(0.1, 0.1),
> offset.text=c(0.1, 0.2))
> p <- ggtree(tree) + xlim(NA, 7)
> p +
+ geom_cladelab(node=45, label="test label", barsize = NA) +
+ geom_cladelab(node=34, label="another clade")
Warning message:
Removed 1 rows containing missing values (geom_segment).
> p +
+ geom_cladelab(node=45, label="test label", barsize = 0) +
+ geom_cladelab(node=34, label="another clade", barsize = 0)
Can you have a look and/or maybe suggest a way of plotting a clade label without a bar? Thank you!
if you want to remove bar plot without warning. you can set barcolor=NA
or barsize=0
. I don't konw why the bar plot was not be removed although you has used barsize=0
. It works on my platform.
library(ggtree)
library(ggplot2)
library(treeio)
library(patchwork)
set.seed(2015-12-21)
tree <- rtree(30)
data <- data.frame(id=c(45, 34),
annote=c("test clade", "another clade"),
image=c("7fb9bea8-e758-4986-afb2-95a2c3bf983d",
"0174801d-15a6-4668-bfe0-4c421fbe51e8"),
group=c("A", "B"),
offset=c(0.1, 0.1),
offset.text=c(0.1, 0.2))
p <- ggtree(tree) + xlim(NA, 7)
p1 <- p +
geom_cladelab(node=45, label="test label", barcolor = NA) +
geom_cladelab(node=34, label="another clade")
p2 <- p +
geom_cladelab(node=45, label="test label", barsize = 0) +
geom_cladelab(node=34, label="another clade", barsize = 0)
p1/p2
I am using RStudio on windows and macOS. On Windows it is shown, on macOS it is not.
In addition I did run a linux docker image on both systems and both times the segment is not shown.
However, the geom_segment
is still visible, if I save the image with ggsave
on Windows and also visibible, if I use RGui on Windows. I guess it is an OS specific issue, but you can address it, if you want, by omiting the addition of the geom_segment, if the barsize is NA
, NULL
or 0
, and not plotting it with a width of 0
. It would be much appreviated