Question: The fonts and size of a tree displayed by ggtree
gravatar for sunyeping
2.2 years ago by
sunyeping30 wrote:

I'm trying to use R package ggtree to visualize my polygenic tree. I use the following codes:

tree <-read.tree(text=as.character(tree_text$V1))
ggtree(tree, layout="daylight") + geom_tiplab(aes(angle=angle))

Some tip labels of the tree are out of the plot region and invisible (Please refer to I use the dev.size("in") command to get the size of the graphic window, and it returns: [1] 5.760417 5.750000. I wish the tree can be displayed in a A4 paper size region, so I try to make a larger graphic window by:

ggtree(tree, layout="daylight") + geom_tiplab(aes(angle=angle))

but it deoesn't work. The dev.size("in") command still returns: [1] 5.760417 5.750000, and some tip labels of the tree are still out of the plot region. If I use ggsave to save the image:

p<-ggtree(tree, layout="daylight") + geom_tiplab(aes(angle=angle))    

it gives an error:

Error in, as.graphicsAnnot(x$label), x$x, x$y,  : 
      family 'sans' not included in postscript() device

If I save the image as pdf file:


the image can be saved, but some tip labels of the tree are still out of the plot region. I try to increase the height and width value in ggsave, but the size of tree increases with the plot canvas, so invisible tip labels are always invisible

Do you know how to correct the problem and display all the complete tip labels of the tree? I will be grateful to any help!

R • 3.5k views
ADD COMMENTlink modified 2.2 years ago by Biostar ♦♦ 20 • written 2.2 years ago by sunyeping30

How about changing the height and width while saving in pdf format. something like this ...

ggsave(filename = "tree.pdf" , device = "pdf", width = 15, height = 30 , units = "in" , limitsize = FALSE)
ADD REPLYlink written 2.2 years ago by Chirag Parsania1.8k

Have you tried to just modify the label size with geom_tiplab?

ADD REPLYlink modified 2.2 years ago • written 2.2 years ago by Kevin Blighe61k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1334 users visited in the last hour