Hi,
I am trying to adjust legend position in one of your example. For p2 graph (heatmap like graph). I am interested in to have legend at the bottom of this graph but instead legend for p2 is always coming to the right of the last inserted graph. Is it possible to change guides position after joining graphs ("What I need" on attached picture)?
Thanks,
Dawid
library(ggplot2)
library(ggtree)
set.seed(2019-10-31)
tr <- rtree(10)
d1 <- data.frame(
# only some labels match
label = c(tr$tip.label[sample(5, 5)], "A"),
value = sample(1:6, 6))
d2 <- data.frame(
label = rep(tr$tip.label, 5),
category = rep(LETTERS[1:5], each=10),
value = rnorm(50, 0, 3))
# tree
g <- ggtree(tr) + geom_tiplab(align=TRUE)
# p1 = bar_graph
p1 <- ggplot(d1, aes(label, value)) +
geom_col(aes(fill=label)) +
geom_text(aes(label=label, y= value+.1)) +
coord_flip() +
theme_tree2() +
theme(legend.position='none')
# heatmap like graph
p2 <- ggplot(d2, aes(x=category, y=label)) +
geom_tile(aes(fill=value)) + scale_fill_viridis_c() +
theme(legend.position="bottom", legend.box = "horizontal") # adding guide positions
# draw final
p2 %>% insert_left(g) %>% insert_right(p1, width=.5)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4