boxplot()命令中有没有办法以45度角旋转标签?
我意识到las = 2命令将它们旋转为垂直于x轴,但我希望它们能够在45度。
答案 0 :(得分:4)
以下内容如何:
# Some sample data
x <- list(x = rnorm(100, 2), y = rnorm(100, 4));
# Plot without x axis
boxplot(x, xaxt = "n");
# Add axis labels rotated by 45 degrees
text(seq_along(x), par("usr")[3] - 0.5, labels = names(x), srt = 45, adj = 1, xpd = TRUE);
PS。或ggplot
中的更简单/更清洁:
require(ggplot2);
require(reshape2);
df <- melt(x);
ggplot(df, aes(L1, value)) + geom_boxplot() + theme(axis.text.x = element_text(angle = 45, hjust = 1));