我注意到有几个graphics
函数(例如,rug()
)不适用于grDevices
颜色修改函数(例如adjustcolor()
,rgb()
等。 )。下面,我提供一些例子。
既然adjustcolor()
和rgb()
不起作用,我想知道rug()
(见下文),我如何产生 透明效果 (又名alpha
参数)在我的rug()
来电中?
即使我运行我们的同事, @AkselA ,rug()
代码(请参阅下面的答案),我也无法复制他的结果。任何建议都表示赞赏。
x = rnorm(1e2)
hist( x )
rug( x , col = adjustcolor("pink" , .5) ) # Doesn't work
rug( x , col = rgb(1, 0, 0 , .5 ) ) # Doesn't work
axis(1 , col = adjustcolor("pink" , .5) ) # Doesn't work
axis(1 , col = rgb(1, 0, 0 , .5 ) ) # Doesn't work
plot( x , col = adjustcolor("pink" , .5) ) # works
plot( x , col = rgb(1, 0, 0 , .5 ) ) # works
答案 0 :(得分:0)
它似乎对我来说非常合适,因为它应该是,因为这两个函数的输出只是一个简单的rgb十六进制字符串,它几乎被普遍接受为R函数中的颜色参数。
x = rnorm(1e2)
par(mfrow=c(1, 3), mar=c(2, 2, 2, 1))
hist(x)
rug(x, col = adjustcolor("red", 1), ticksize=0.05, lwd=0.6)
hist(x)
rug(x, col = adjustcolor("red", 0.3), ticksize=0.05, lwd=0.6)
hist(x); adjustcolor("red", 0.3)
rug(x, col = "#ff00004D", ticksize=0.05, lwd=0.6)
也许有些东西与设备有关。如果你尝试
会发生什么png("rugRedTransparent.png", 550, 400)
hist(x)
rug(x, col = "#FF00004D", ticksize=0.05, lwd=1)
dev.off()