rheatmapphylogenyggtree

set x axis on ggtree heatmap in R


I would like to set x axis on a heatmap ggtree.

This is my code

ggtree(working_tree,open.angle=15, size=0.1) %<+% avian %<+% color +
  aes(color = I(colour)) +
  geom_tippoint(size = 2,) +
  geom_tiplab(size = 3, colour = "black") +
  theme_tree2()

# I want to rotate the x axis and get the positive number
p1 <- revts(p) + scale_x_continuous(labels = abs)  

h1 <- gheatmap(p1, landuse, 
               offset = 15, width = 0.05, font.size = 3, colnames_position = "top", colnames_angle = 0,
               colnames_offset_y = 0, hjust = 0) +
  scale_fill_manual(breaks = c("Forest", "Jungle rubber", "Rubber", "Oil palm"),
                    values = c("#458B00", "#76EE00", "#1874CD", "#00BFFF"), name = "Land use system",
                    na.value = "white")

, and I got this picture enter image description here The problem is that when I showed the heatmap, the x axis automatically changes the range itself from 0 to 60. However, the range I want is from 0 to 80.

Does anyone know how to do this or have any experiences for this?


Solution

  • Updated

    I already solved the case by using the function scale_x_continous like this

    scale_x_continuous(breaks = seq(-80,0,20), labels = abs(seq(-80,0,20)))

    For anyone interested in geological timescale in R, I suggest to use the package deeptime