YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
830 stars 172 forks source link

Issue with angled unrooted tree label #528

Open PSSchacksen opened 2 years ago

PSSchacksen commented 2 years ago

When making an unrooted tree and flipping it using e.g. coord_flip() or visualized using ggplotify::as.ggplot(angle=-30, scale=.9) the angle of the labels aren't following the flip, but keeps the original angle. Is there a way to make the angles follow the flipped tree?

Code I'm using for visualization: nosZ_comb_muscle_unrooted_daylight <- ggtree(nosZ_muscle, layout = "daylight")

nosZ_comb_muscle_unrooted_daylight_label <- nosZ_comb_muscle_unrooted_daylight%<+%nosZ_tax + geom_tiplab(aes(label=Phylum, angle=angle), size = 2) + geom_cladelab(node=857, label="Acidobacteriota", textcolor='black', fontsize=2.5, barsize=NA, offset = -0.15, angle = "auto") + geom_cladelab(node=851, label="Spirochaetota", textcolor='black', fontsize=2.5, barsize=NA, offset = 0.0, angle = "auto") + ... other nodes

nosZ_comb_muscle_unrooted_daylight_col <- collapse(nosZ_comb_muscle_unrooted_daylight_label, node = 857, 'mixed', fill="grey", alpha= 0.6) %>% collapse(851, 'mixed', fill="grey", alpha= 0.6) %>% collapse(545, 'mixed', fill="grey", alpha= 0.6) %>% ... remaining nodes

a <- nosZ_comb_muscle_unrooted_daylight_col b <- nosZ_comb_muscle_unrooted_daylight_col + coord_flip()

grid.arrange(a, b) image

cfz1998 commented 1 year ago

Hi! @GuangchuangYu I have the same error! How to fix it> image

Thank you for your reply!