how can I joint ggsankey and a dotplot?
Opened this issue · 2 comments
Sagityq commented
Hi:
I put it together myself. The coordinates don't match:
This is what I'm looking for:
my code:
library(ggplot2)
library(ggsankey)
library(dplyr)
pl <- ggplot(dat3, aes(x = x,
next_x = next_x,
node = node,
next_node = next_node,
fill = factor(node),
label = node2
)) +
geom_sankey(flow.alpha = 0.5, node.color = "black") +
geom_sankey_label(size = 6, color = "black", fill = "white", hjust = 1, family = "Times") +
scale_fill_viridis_d(option = "magma") +
theme_sankey(base_size = 16) +
scale_x_discrete(expand = c(0.01,0.1)) +
theme(legend.position = "none",
axis.title = element_blank(),
axis.text = element_blank())
pl
library(clusterProfiler)
kk_dot <- dotplot(kk, showCategory=10) +
theme(text = element_text(family = "Times"),
axis.text.y = element_text(size = 12, face = "bold"),
axis.text.x = element_text(size = 10, face = "bold"),
axis.title.x = element_text(size = 14, face = "bold"),
legend.title = element_text(face = "bold"))
kk_dot
kk_dot2 <- kk_dot + theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank())
library(patchwork)
design <- c("
AAAA#
AAAAB
AAAAB
AAAAB
AAAA#
")
all_p <- pl + kk_dot2 + theme(text = element_text(size = 20),
axis.title.x = element_text(size = 25),
axis.text.x = element_text(size = 20)) +
plot_layout(design = design)
all_p
Looking forward to your reply!
microbioin commented
Actually, the reference figure was plotted with our SRplot online website, written in pysankey2 and matplotlib. We set the height of the right sankey the same to the height of right dot plot. Hope this can help you.