繁体   English   中英

是否在R中以45度角在箱形图中插入标签?

[英]Inserting labels in box plot in R on a 45 degree angle?

boxplot()命令中是否可以将标签旋转45度角?

我意识到las = 2命令将它们旋转为垂直于x轴,但是我希望它们成45度角。

怎么样:

# 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更容易/更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));

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM