ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Scale on the y-axis in a tree rotated with 'layout_dendrogram()'

Open gvaleman opened this issue 2 years ago • 1 comments
trafficstars

I'm editing a time-scaled tree using ggtree. The dates are correctly adjusted when I apply the 'mrsd' command and 'theme_tree2()', but when I try to rotate the tree with 'layout_dendrogram()', the scale still remains on the x-axis with no dates. Is there a way to place the date scale on the y-axis in a tree rotated with 'layout_dendrogram()'?

# Code without layout_dendrogram()
ggtree(my_tree, mrsd='2022-12-31') %<+% 
  metadato_arbol + 
  geom_tippoint(size = 2) + 
  theme_tree2()

image

# Using layout_dendrogram()
ggtree(my_tree, mrsd='2022-12-31') %<+% 
  metadato_arbol + 
  geom_tippoint(size = 2) + 
  theme_tree2() + layout_dendrogram()

image

gvaleman avatar Aug 22 '23 20:08 gvaleman

I have the same problem (in #598).

This is my current workaround:

library(ape)
library(ggtree)
library(ggplot2)

n = 50
t = rcoal(n)

ggtree(t) + 
  layout_dendrogram() +
  theme(axis.ticks.y = element_line(),
        axis.line.y = element_line(),
        axis.text.y = element_text())

Although it doesn't seem to allow custom tip labels(e.g. 20k instead to 20000), for a reason I cannot figure out.

SamPassmore avatar Jan 24 '24 05:01 SamPassmore