? Tue, 19 Sep 2023 13:21:08 +0900 ani jaya <gaaauul at 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, Ivan
Thank you very much for the help. Turn out I can use 'density' to differentiate the overlaid area. On Tue, Sep 19, 2023, 16:16 Ivan Krylov <krylov.r00t at gmail.com> wrote:> ? Tue, 19 Sep 2023 13:21:08 +0900 > ani jaya <gaaauul at 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, > Ivan >[[alternative HTML version deleted]]
Shorter/simpler alternative for adding a alpha channel adjustcolor("lightblue", alpha = 0.5) So I would use something like: # Open new plot; make sure limits are ok; but don't plot plot(0, 0, xlim=c(1,20), ylim = range(c(mean1+sd1, mean2+sd2, mean1-sd1, mean2-sd2)), type="n", las=1, xlab="Data", ylab=expression(bold("Val")), cex.axis=1.2,font=2, cex.lab=1.2) polygon(c(1:20,20:1), c(mean1[1:20]+sd1[1:20],mean1[20:1]-sd1[20:1]), col=adjustcolor("blue", 0.5), border = NA) polygon(c(1:20,20:1), c(mean2[1:20]+sd2[1:20],mean2[20:1]-sd2[20:1]), col=adjustcolor("yellow", 0.5), border = NA) lines(1:20, mean1,lty=1,lwd=2,col="blue") lines(1:20, mean2,lty=1,lwd=2,col="yellow") On 19-09-2023 09:16, Ivan Krylov wrote:> ? Tue, 19 Sep 2023 13:21:08 +0900 > ani jaya <gaaauul at 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. >