1

我正在绘制条形图并面临以下问题:

条形图由负值和正值组成。我想在每个栏的末尾显示这些值。当我选择 pos=4 时,正值显示得很好,但负值不太好。当我选择 pos=2 时,同样的问题也会发生,反之亦然......

我能做什么...请找到我的附言:

par(pin=c(9,9), mar=c(1,12,1,1), col=c(rgb(126,126,126,maxColorValue=255)), xpd=F)
PBG <- barplot(Gewicht_tsr, beside=T, horiz=T, space= c(.5,1), las=2,
               cex.name=0.7, xlim=c(min(Gewicht_d)*1.7, max(Gewicht_d)*1.7),
               border=NA, axes=F, main="Sektoren Gewichtung", 
               col=c(rgb(206,165,90,maxColorValue=255),
                     rgb(180,169,162,maxColorValue=255),
                     rgb(0,116,77,maxColorValue=255)), 
               col.axis=c(rgb(126,126,126,maxColorValue=255)),
               col.main=c(rgb(126,126,126,maxColorValue=255)), width=.8)
legend("bottomright", legend=c("Portfolio", "Benchmark", "Aktiv"),
       ncol=3, pch=15, bty="n",
       col=c(rgb(0,116,77,maxColorValue=255),
             rgb(180,169,162,maxColorValue=255),
             rgb(206,165,90,maxColorValue=255)),
       cex=0.7)
y <- (as.matrix(Gewicht_tsr [,1:ncol(Gewicht_tsr)]))
text(y,PBG, labels=as.character(y), cex=0.62, pos=4)

所有其他事情都很好。

4

0 回答 0