【发布时间】:2017-11-14 03:58:12
【问题描述】:
boxplot() 命令中是否有任何方法可以将标签旋转 45 度角?
我意识到 las=2 命令将它们旋转到垂直于 x 轴,但我希望它们处于 45 度角。
【问题讨论】:
标签: r
boxplot() 命令中是否有任何方法可以将标签旋转 45 度角?
我意识到 las=2 命令将它们旋转到垂直于 x 轴,但我希望它们处于 45 度角。
【问题讨论】:
标签: r
以下内容如何:
# 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));
【讨论】: