【发布时间】:2014-08-18 21:39:26
【问题描述】:
我是使用 RStudio 的新手,所以如果我忽略了解决问题的明显方法,请原谅我。
我在 r 中制作了一个几乎正确的箱线图,除了我想更改 x 轴标签/文本的对齐方式/或大小。
我目前使用的是 RStudio 版本 3.1,但自 R 版本 2.13.1 (2011-07-08) 以来发生了一些变化平台:x86_64-pc-mingw32/x64 (64-bit) as code from then, is not working对我来说。
有 2 个物种和 5 个处理,目的是绘制一个具有物种和处理之间相互作用的箱线图,排列成物种 1 治疗 1,物种 2 治疗 1,物种 1 治疗 2,物种 2 治疗2等
目前有效的代码是:
pseudodata <- read.csv(file.choose(), header=TRUE)
pseudodata$agg_count <- rep(1:60, each=2)
data <- aggregate(pseudodata , by=list(pseudodata$agg_count), FUN=mean)
boxplot (Force..N. ~ interaction(data$Species, data$Treatment),
data=data, col=(c("gold","darkgreen")),
xlab="Species and Treatment", ylab="Force of detachment (N)")
这产生了一个与Second boxplot with colour notched 非常相似的箱线图
但是 x 轴文本标签并未全部显示,所以我想将它们设置为 45o 角。
我试过了:
labels <- c("Helix.Copper", "Hibernica.Copper","Helix.Easy on", "Hibernica.Easy on",
"Helix.Pegagraff", "Hibernica.Pegagraff", "Helix.Untreated",
"Hibernica.Untreated", "Helix.Zinc", "Hibernica.Zinc")
forceplot <- boxplot(Force..N. ~ interaction(data$Species, data$Treatment),
data=data, # dataframe used
xaxt="n", # suppress the default x axis
col=(c("gold","darkgreen")),
xlab="Species and Treatment", ylab="Force of detachment (N)")
Text(forceplot, par(“usr”)[3], labels = labels, srt = 45,
adj = c(1.1,1.1), xpd = TRUE, cex=.9)
)
axis(2)
但是似乎不起作用,我不知道为什么。如果有人对如何创建这个情节有任何想法,我将不胜感激。
【问题讨论】:
标签: r plot boxplot axis-labels