data(Arbuthnot, package="HistData")

Building a custom graph in base graphics

Construct a basic line plot, with graphical enhancements

op <- par(mar=c(4,4,1,1)+.1)
plot(Ratio ~ Year, data=Arbuthnot,
    pch=16,
    ylim=c(1, 1.20), 
    cex.lab = 1.3,
    ylab="Sex Ratio (M/F)")

# connect points by lines
lines(Ratio ~ Year, data=Arbuthnot, col="gray")

# add reference line 
abline(h=1, col="red", lwd=3)
text(1640, 1, "Males = Females", pos=3, col="red")

# add linear regression line
abline(lm(Ratio ~ Year, data=Arbuthnot), col="darkgreen")

#  add loess smooth
Arb.smooth <- with(Arbuthnot, loess.smooth(Year,Ratio))
lines(Arb.smooth$x, Arb.smooth$y, col="blue", lwd=2)

# add internal figure caption
text(1690, 1.19, "Arbuthnot's data on the\nMale / Female Sex Ratio", cex=1.2)

par(op)

The same with ggplot2

library(ggplot2)

ggplot(Arbuthnot, aes(x=Year, y=Ratio)) +
    ylim(1, 1.20) + 
    ylab("Sex Ratio (M/F)") +
    geom_point(pch=16, size=2) +
    geom_line(color="gray") +
    geom_smooth(method="loess", color="blue", fill="blue", alpha=0.2) +
    geom_smooth(method="lm", color="darkgreen", se=FALSE) + 
    geom_hline(yintercept=1, color="red", size=2) +
    annotate("text", x=1640, y=1.005, label="Males = Females", color="red", size=4) +
    annotate("text", x=1690, y=1.19, label="Arbuthnot's data on the\nMale / Female Sex Ratio", size=6) +
    theme_bw()