Is there a way to remove the blank lines from a geom_tile plot? If I try scale = "free"
it looks weird. I want to preserve the width and height of each facet.
Here is my code:
data.m <- melt(data, id.vars=c("Group","miRNA"))
head(data.m)
# Group miRNA variable value
# 1 Serum hsa-let-7d-5p 1_0h_rep1 0.5356346
# 2 Serum hsa-let-7e-5p 1_0h_rep1 0.5994119
# 3 Serum hsa-let-7g-5p 1_0h_rep1 0.5097298
# 4 Serum hsa-miR-106a-5p 1_0h_rep1 0.3566843
# 5 Serum hsa-miR-1180-3p 1_0h_rep1 0.6019190
# 6 Serum hsa-miR-152-5p 1_0h_rep1 0.1815842
p <- ggplot(data.m, aes(variable, miRNA))
p + geom_tile(aes(fill = value)) + facet_wrap(~Group,ncol=1) +
scale_fill_gradient2(low=muted("blue"), high=muted("red")) +
scale_x_discrete(labels=c("0h_rep2", "0h_rep1", "1h_rep2","1h_rep1","4h_rep2","4h_rep1","9h_rep2","9h_rep1", "15h_rep2", "15h_rep1","18h_rep2","18h_rep1","21h_rep2","21h_rep1")) +
theme_bw(base_size=20) +
theme(axis.text.x=element_text(angle=0, vjust=0.5, hjust=0, size=12), axis.text.y=element_text(size=12), strip.text.y=element_text(angle=0, vjust=0.5, hjust=0.5, size=12),
strip.text.x=element_text(size=12)) +
labs(y="Genes", x="Time (h)", fill="")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…