Skip to content

Instantly share code, notes, and snippets.

@dmarcelinobr
Last active December 18, 2015 20:58
Show Gist options
  • Save dmarcelinobr/5843638 to your computer and use it in GitHub Desktop.
Save dmarcelinobr/5843638 to your computer and use it in GitHub Desktop.
# rm(list = ls()) # clear objects
# graphics.off() # close graphics windows
plot.new() # call new plot window
x = seq(-5,5, length=250)
y = dnorm(x)
plot(x,y, las=1, ylab='dnorm', type='n', yaxs='i', ylim=c(0, 0.5))
x2 = seq(qnorm(0.95), 5, length=50)
y2 = dnorm(x2)
polygon(c(x2[1], x2, x2[length(x2)]), c(0, y2, 0), border=NA, col='grey')
lines(x, y)
lines(c(2.5, 2.1), c(0.1, 0.02))
text(2.5, 0.115, expression(alpha==0.05))
box() # thanks for YR's remark
dev.copy(jpeg, 'polygon.jpeg') # save plot as .jpeg
#dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment