YuLab-SMU / aplot

Decorate a plot with associated information
https://yulab-smu.top/aplot
92 stars 14 forks source link

use original scale when sub plot is not ggtree #23

Closed xiangpin closed 1 year ago

xiangpin commented 1 year ago

when subplot is no ggtree object, the position of the axis label can not be adjusted.

library(ggplot2)
library(tibble)
library(aplot)
set.seed(20200618)
gmat <- expand.grid(x = letters[1:10], y = letters[1:10])
gmat$v <- rexp(100, rate=.1)
gbar <- tibble(x = letters[1:10], y = round(runif(10) * 100,1))
pmat <- ggplot(gmat, aes(x,y, fill=v)) + geom_tile()
pbar <- ggplot(gbar, aes(x, y)) + geom_col()
pbar + scale_x_discrete(position='top') + coord_flip() -> pbar1
pmat %>% insert_top(pbar + scale_x_discrete(position='top'))

xx

> pmat %>% insert_right(pbar1)

捕获

This pr fix the issue

pmat %>% insert_top(pbar + scale_x_discrete(position='top'))

xx

> pmat %>% insert_right(pbar1)

捕获