1. LON-CAPA Logo
  2. Help
  3. Log In
 

Browsing resource, all submissions are temporary.


polygon() Function

a. Run the following commands:

x <- c(1,2,3,4)
y <- c(0,1,1,0)
plot(x,y)
polygon(x,y,col="blue")

What do you see?




 Tries 0/1

b. Run the following commands:

x1 <- -1
y1 <- 0
x2 <- 1.5
y2 <- 0
xcurve <- c(-1,0,1.5)
ycurve <- dnorm(xcurve)
x <- c(x1, xcurve, x2)
y <- c(y1, ycurve, y2)
curve(dnorm(x), xlim=c(-3,3))
polygon(x,y, col="gold")

What do you see?





 Tries 0/2

c. Run the following commands:

xstart <- 1.2
ystart <- 0
xend <- 4
yend <- 0
xcurve <- seq(xstart, xend, length.out=100)
ycurve <- dnorm(xcurve)
x <- c(xstart, xcurve, xend)
y <- c(ystart, ycurve, yend)
curve(dnorm(x), xlim=c(-xend,xend))
polygon(x,y, col="skyblue")

What do you see?





 Tries 0/2