[R] Polygon

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Tue Oct 2 18:51:35 CEST 2018


Hello,

Continue with


polygon(-rev(cord.x), rev(cord.y), col = 'skyblue')


Hope this helps,

Rui Barradas

Às 17:25 de 02/10/2018, Steven Yen escreveu:
> Can someone help me with polygon. The following codes are self-runnable
> and mark a shaded area under the standard normal curve in the x-range
> (-3,-1).
> Is there a way to also mark the area in (1,3), at the same time.
> That is, I want shaded areas in both tails. Thank you...
> 
> ===
> # Create data for the area to shade
> cord.x <- c(-3,seq(-3,-1,0.01),-1)
> cord.y <- c(0,dnorm(seq(-3,-1,0.01)),0)
> 
> # Make a curve
> curve(dnorm(x,0,1), xlim=c(-3,3), main='Standard Normal')
> 
> # Add the shaded area.
> polygon(cord.x,cord.y,col='skyblue')
>




More information about the R-help mailing list