【发布时间】:2013-12-26 11:59:44
【问题描述】:
我有以下代码用渐变绘制箭头:
csa <- function(x1,y1,x2,y2,first.col,second.col,length=0.15, ...) {
cols <- colorRampPalette( c(first.col,second.col))(250)
x <- approx(c(0,1),c(x1,x2), xout=seq(0,1,length.out=251))$y
y <- approx(c(0,1),c(y1,y2), xout=seq(0,1,length.out=251))$y
arrows(x[250],y[250],x[251],y[251], col=cols[250],length=length, ...)
segments(x[-251],y[-251],x[-1],y[-1],col=cols, ...)
}
color.scale.arrow <- Vectorize(csa, c('x1','y1','x2','y2') )
# Create sample data
x <- c(1,3,5,3,2,1,6,2)
y <- c(2,5,3,7,2,1,5,6)
x1 <- c(1,3,5,3)
y1 <- c(2,5,3,7)
x2 <- c(2,1,6,2)
y2 <- c(2,1,5,6)
# Plot sample data
plot(x,y, main='')
color.scale.arrow(x1,y1,x2,y2,'#5F9EA0','#CD3333',lwd=2)
这幅图的制作者:
我想让这些线条透明,但不幸的是,简单地在颜色代码中添加 50(即透明度的比例 = 50%)不起作用:
# Plot sample data (transparent?)
plot(x,y, main='')
color.scale.arrow(x1,y1,x2,y2,'#5F9EA050','#CD333350',lwd=2)
知道为什么这不起作用,以及如何使这些线条透明吗?
【问题讨论】:
标签: r colors plot transparency