0

I'm using the R package ggtree to plot phylogenetic tree in R.

I have sucessfully produced the phylogenetic tree I was interested in, however, I have difficulties in adding a 'legend' to my figures.

I have tried the suggestions present in this post Add legend into ggtree (ggplot) R but it did not work. I did not find others.

Do you have any suggestion?

This is the command I'm running:

 plot<-ggtree(new.tree,layout=phylo_method)+geom_nodepoint(size=c(NA,size_node),colour=c(NA,col_node),pch=8,na.rm =TRUE)+
  geom_tiplab(align=FALSE, linetype='dashed', linesize=.3,size=2)+
  geom_tippoint(color=raxml_col, size=2, show.legend = TRUE)+
  theme(legend.position="right")
CafféSospeso
  • 1,101
  • 3
  • 11
  • 28
  • You don't have anything mapped to an aesthetic scale from which a legend can be constructed. Have you tried `mapping = aes(colour = col_node)` instead of `colour=c(NA,col_node)` inside `geom_nodepoint`? – Allan Cameron Sep 04 '20 at 13:42
  • I wanted actually to add a legend on the colours used in the geom_tipppoint. I have tried your suggestion on the geom_tipppoint, but I get the following error: 'Error: Aesthetics must be either length 1 or the same as the data (121): colour' – CafféSospeso Sep 05 '20 at 16:03

0 Answers0