ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Angle of tip label wrong after using rotate with a fan tree

Open Ekie22 opened this issue 3 years ago • 0 comments
trafficstars

Hello, after I rotate a node in a fan tree the tip labels are wrongly displayed. Adding an angle to geom_tiplab does not change anything. Is their a way to correct the angle? Thanks ggtree version 3.5.0.900 ggplot version 3.3.6

library("ggplot2")
library("ggtree")
library("dplyr")


# ##################################
# load example tree from package
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)

# ##################################
# fan tree
gg <- ggtree(tree, layout = "fan", open.angle = 180)

# generate long tip labels
x <- gg$data[gg$data$isTip=="TRUE", "label"] %>%
  mutate(long_name = paste("long_tip_label", label, sep = "_"))

gg <- gg %<+% x
gg 

# original with long tip label
gg + geom_tiplab(aes(label = long_name)) +  xlim(0, 90)

ggtree_issue_fan_ori

After rotate:

# rotated fan with long tip label
gg %>% rotate(16)  + geom_tiplab(aes(label = long_name)) +  xlim(0, 90)

ggtree_issue_fan_rotated

Ekie22 avatar May 13 '22 11:05 Ekie22