我想知道是否可以在R中绘制带有轮廓的文本,这样文本可以独立于背景读取(如模因文本).以下(显然)失败:
# prepare a colorful background
randcolors <- sprintf( "#%02X%02X%02X99", sample(1:255, 1000, replace=T), sample(1:255, 1000,replace=T), sample(1:255, 1000, replace=T))
plot( NULL, xlim=c(0,1), ylim=c(0,1), xaxt="n", bty="n", yaxt="n")
points( runif(1000, 0, 1 ), runif( 1000, 0, 1 ), cex=runif(1000, 0.5, 5), col= randcolors, pch= 19)
text( 0.5, 0.5, "test text", cex= 5 )
text( 0.5, 0.5, "test text", cex= 4.5, col="white" )
Run Code Online (Sandbox Code Playgroud)
结果并不壮观:

显然,我可以先创建一个白色或半透明的背景,但实际上我更喜欢有漂亮的轮廓.
尝试shadowtext从TeachingDemos包:
shadowtext( 0.5, 0.5, "test text", cex= 4.5, col="white" , r=0.3)
Run Code Online (Sandbox Code Playgroud)
