2015-08-19 20 views
0

我已這是爲了說 AY標籤「A. stutchburyi豐 (#個人/0.50米^ 2)」,其中#個人....假定成爲第二行R:需要Ý標籤是兩行

問題是,我不能讓它工作,因爲我混合不同的字體(正常和斜體)。通常我使用\ 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) 
+2

我們需要'tsa'作爲一個可重複的例子。此外,R/RStudio和StackOverflow都不會爲空格和換行符收取更多費用。不需要使代碼看起來像最小化的JavaScript。 – hrbrmstr

回答

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

+0

我試過了你提供的代碼,以及上面提到的那個,但是這隻把「#個人......」當作'(^)'的標籤的第一部分的...「 – user3679579

+0

你確定你沒有混淆Jaap的答案嗎?我的回答很好。 –

+0

啊,現在它工作了,謝謝,謝謝! – user3679579