Connect your dots when the X axis is ordered

A collection of common dataviz caveats by

Let’s consider a dataset composed by two numeric variables. The X axis represents years, and the Y axis the yearly sunspot numbers from 1749 to 1983. (Sunspots are temporary phenomena on the Sun’s photosphere that appear as spots darker than the surrounding areas.). The dataset comes from this scientific publication originally, related by Andrews et al..

# Libraries

# Load dataset: comes with R
data <- data.frame(
  Year = as.numeric(time(sunspot.year)),
  Sunspots = as.numeric(sunspot.year)

# Plot
data %>%
  head(100) %>%
  ggplot( aes(x=Year, y=Sunspots)) +
    geom_point() +
    ggtitle("Number of sunspots per year") +
    theme_ipsum() +
      plot.title = element_text(size=12)