简体   繁体   中英

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 在此处输入图像描述 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM