Hi there,
Given a tree with tip labels colored by a group eg:
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)
meta = data.frame(label = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"),
group = c(rep("mammal", 5), rep("insect", 5), rep("bird", 3)))
p = ggtree(tree) %<+% meta +
geom_tiplab(aes(color = group))
The legend will contain 'a' instead of the desired square. ggplot documentation says to use "override.aes" to override this behavior:
p + guides(color = guide_legend(override.aes = list(size = 4,
label = "",
shape = 15)))
This does not work. The overriding works, I can change the size, colors, remove the 'a' but most importantly I can't use a different shape (in this case a square).
Newer version of ggplot2 have the key_glyph option, but this too has no effect when using "geom_tiplab".
Another odd behavior is that when using "geom_tipppoint", overriding the legend works.
Any advice on how to override geom_tiplab() legend shape?
My environment:
R version 4.1.2 (2021-11-01)
ggplot2 version 3.3.5
ggtree version 3.2.1
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20