【发布时间】:2015-05-31 22:42:36
【问题描述】:
我想知道是否可以在 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" )
结果并不壮观:
显然,我可以先创建一个白色或半透明的背景,但实际上我更喜欢有漂亮的轮廓。
【问题讨论】:
-
此链接可能会有所帮助:stackoverflow.com/questions/7734535/…
-
ggplothere 的一些可能性。