我想在一个情节中添加一个数字和%符号。例如,我希望东北象限说24.7%而不是24.7%。任何帮助是极大的赞赏。以下是最低工作示例:
Sigma <- matrix(c(1,0,0,1),2,2)
Coefsim = rmvnorm(1000, c(0, 0), Sigma )
NE = sum( Coefsim[,1] > 0 & Coefsim[,2] > 0 )/10
NW = sum( Coefsim[,1] < 0 & Coefsim[,2] > 0 )/10
SE = sum( Coefsim[,1] > 0 & Coefsim[,2] < 0 )/10
SW = sum( Coefsim[,1] < 0 & Coefsim[,2] < 0 )/10
plot(Coefsim[,1],Coefsim[,2], pch = 16, cex = .4, xlab = expression(hat(beta)), ylab = expression(hat(phi)), las=1)
abline(a=NULL, b=NULL, h=0, v=0,col=c("red", "red"))
text(2.5, 2.5, NE)
text(2.5, -2.5, SE)
text(-2.5, 2.5, SW)
text(-2.5, -2.5, NW)
答案 0 :(得分:0)
您可以在将值添加到绘图之前对其进行转换:
Sigma <- matrix(c(1,0,0,1),2,2)
Coefsim = rmvnorm(1000, c(0, 0), Sigma )
NE = sum( Coefsim[,1] > 0 & Coefsim[,2] > 0 )/10
NW = sum( Coefsim[,1] < 0 & Coefsim[,2] > 0 )/10
SE = sum( Coefsim[,1] > 0 & Coefsim[,2] < 0 )/10
SW = sum( Coefsim[,1] < 0 & Coefsim[,2] < 0 )/10
NE <- c(as.character(NE), "%")
NE <- paste0(NE, collapse = "")
NW <- c(as.character(NW), "%")
NW <- paste0(NW, collapse = "")
SE <- c(as.character(SE), "%")
SE <- paste0(SE, collapse = "")
SW <- c(as.character(SW), "%")
SW <- paste0(SW, collapse = "")
plot(Coefsim[,1],Coefsim[,2], pch = 16, cex = .4, xlab =
expression(hat(beta)), ylab = expression(hat(phi)), las=1)
abline(a=NULL, b=NULL, h=0, v=0,col=c("red", "red"))
text(2.5, 2.5, c(NE))
text(2.5, -2.5, SE)
text(-2.5, 2.5, SW)
text(-2.5, -2.5, NW)