我正在制作geom_tile
ggplot
,我的x轴刻度标签很长:
set.seed(1)
df <- data.frame(sample = c(rep(paste(rep("S1",30),collapse=""),30),
rep(paste(rep("S2",30),collapse=""),30),
rep(paste(rep("S3",30),collapse=""),30)),
gene = rep(paste("G", 1:30, sep = ""), 90),
value = rnorm(90))
因此,当我制作情节时,他们会被切断:
require(ggplot2)
ggplot(df, aes(x = sample, y = gene)) +
geom_tile(aes(fill = value)) +
scale_fill_gradient2(high = "darkred", low = "darkblue") +
theme_bw() +
theme(legend.key = element_blank(),
legend.position = "right",
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
panel.border = element_blank(),
strip.background = element_blank(),
axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
我该如何解决这个问题?