plot.frequency.polygon <- function(n=6) { data=rnorm(5000, mean=14, sd=2) data <- data[data>8 & data<=20] h<-hist(x=data, breaks=seq(8, 20, length=n+1), plot=FALSE) # compute the frequency polygon diffBreaks <- h$mids[2] - h$mids[1] xx <- c( h$mids[1]-(diffBreaks/2), h$mids, tail(h$mids, 1)+(diffBreaks/2) ) yy <- c(0, h$density, 0) # draw the histogram hist(x=data, breaks=seq(8, 20, length=n+1), prob = TRUE, border="gray", col="gray90", xlab="βαθμοί", ylab="σχετική συχνότητα", main="", cex.lab=1.5, cex.axis=1.5, family="serif") lines(xx, yy, lwd=2, col ="royalblue") mtext(text=as.expression(substitute("πλήθος κλάσεων"==n)), col="red", family="serif", cex=1.8) }