R:需要y标签为两行

时间:2015-08-19 10:41:04

标签: r plot label expression

我有一个y标签应该说 “丰富的 A.stutchburyi (#somers / 0.50m ^ 2)“其中#个人......应该是第二行

问题是,由于我混合了不同的字体(普通和斜体),我无法使其工作。通常我使用\ n但是在表达式中不起作用..

这是我的代码,它只在一行上给我y标签:

tsaplot <- barplot(tsa$No, beside = TRUE,
                   xlab = "Size groups (mm)",
                   ylab = expression(atop(paste("Abundance of",italic("A. stutchburyi"),"(# individuals / 0.50m^2)"))),
                   cex.axis = 1.4, density = 50, font.lab = 2, font.axis = 2, cex.lab = .9, col = "black",
                   names.arg = c("0-2.0","2.1-4.0","4.1-6.0","6.1-8.0","8.1-10.0","10.1-12.0","12.1-14.0","14.1-16.0","16.1-18.0","18.1-20.0",">20.1"),
                   ylim = c(0,100), xpd = FALSE)

1 个答案:

答案 0 :(得分:2)

可能是支架的错位:

tl <- bquote(atop(paste("Abundance of ",italic("A. stutchburyi")),"(# individuals / 0.50"*m^2 ~ ")"))

par(mar = c(5.1, 6.1, 4.1, 2.1))
plot(1, 1, t = "n", ylab = tl)
text(1, 1, tl)

enter image description here

使用barplot

par(mar = c(5.1, 6.1, 4.1, 2.1))
barplot(VADeaths, ylab = tl)

enter image description here