这有效:
plot(1:10, col=rgb(0,0,0,1))
rug(1:10, col=rgb(0,0,0,1))
这不起作用(不另外绘制地毯):
plot(1:10, col=rgb(0,0,0,0.9))
rug(1:10, col=rgb(0,0,0,0.9))
为什么呢?我该如何解决这个问题?
我之所以需要这个是因为我想添加alpha颜色以便重叠" rugs"更黑了。如果没有能够指定alpha颜色,我只能绘制这个:
plot(rep(1:10,100), rep(1:10,100), col=rgb(0,0,0,1))
rug(jitter(rep(1:10,100)), col=rgb(0,0,0,1))
答案 0 :(得分:3)
# This is quite easy to do with ggplot2
# data
df = data.frame(x = rep(1:10,100), y = rep(1:10,100))
# code
library(ggplot2)
ggplot(df, aes(x=x, y=y)) +
geom_point() +
geom_rug(sides="b", position="jitter", alpha=0.2, colour="blue") +
scale_x_continuous(breaks=seq(0,10,by=2)) +
scale_y_continuous(breaks=seq(0,10,by=2))