I'm trying to use R package ggtree to visualize my polygenic tree. I use the following codes:
library(ggtree)
library(treeio)
tree_text<-read.table("tree.nwk")
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 https://www.dropbox.com/s/87gyusx7ay1xxu8/tree.pdf?dl=0). 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:
windows(height=8,width=8)
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))
ggsave("tree.eps",p,height=8,width=8)
it gives an error:
Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
family 'sans' not included in postscript() device
If I save the image as pdf file:
postscript("tree.pdf",family="Times",fonts="sans")
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!
How about changing the height and width while saving in pdf format. something like this ...
Have you tried to just modify the label size with geom_tiplab?