[R] overlay shaded area in base r plot

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Sep 19 09:16:54 CEST 2023

В Tue, 19 Sep 2023 13:21:08 +0900
ani jaya <gaaauul using gmail.com> пишет:

> polygon(c(1:20,20:1),c(mean1[1:20]+sd1[1:20],mean1[20:1]),col="lightblue")
> polygon(c(1:20,20:1),c(mean1[1:20]-sd1[1:20],mean1[20:1]),col="lightblue")
> polygon(c(1:20,20:1),c(mean2[1:20]+sd2[1:20],mean2[20:1]),col="lightyellow")
> polygon(c(1:20,20:1),c(mean2[1:20]-sd2[1:20],mean2[20:1]),col="lightyellow")

If you want the areas to overlap, try using a transparent colour. For
example, "lightblue" is rgb(t(col2rgb("lightblue")), max = 255) →
"#ADD8E6", so try setting the alpha (opacity) channel to something less
than FF, e.g., "#ADD8E688".

You can also use rgb(t(col2rgb("lightblue")), alpha = 128, max = 255)
to generate hexadecimal colour strings for a given colour name and
opacity value.

Best regards,

More information about the R-help mailing list