Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making plot abline lines transparent

Tags:

plot

r

colors

line

I would like to use the function abline to plot several lines which should be made transparent but I am stuck.

Currently I have this code:

plot(x=NA, type="n", ylim=c(1, 9), xlim=c(1, 4), xlab="x-value",
 ylab="y-value", cex.axis = 1, cex.lab = 1)

for (i in 1:nrow(one_hundred_regressions)) {abline(coef=one_hundred_regressions[i,],
                                                col = "red")}
like image 564
Moritz Avatar asked Sep 06 '25 03:09

Moritz


1 Answers

Use adjustcolor changing the alpha value to whatever degree of transparency you want:

plot(1:10)
abline(v = 1:10, col = adjustcolor("red", alpha = 0.3))

screenshot

like image 172
G. Grothendieck Avatar answered Sep 07 '25 22:09

G. Grothendieck