Multiple subtitles with multiple font sizes?

Just wondering, is it possible in ggplot2 to have 2 subtitles -- 1 with a smaller font size than the other?

ggplot text elements (not sure about the label aesthetic) accept expressions. Check out ?plotmath to see what's possible. For sub-subtitles:

library(ggplot2)

ggplot() +
  labs(
    title    = "Title size",
    # Plotmath works on expressions
    subtitle = expression(
      # Plotmath expressions can't use "\n", so this vertically arranges
      atop(
        "Subtitle size",
        atop(
          # Small font
          scriptstyle("Small"),
          # Tiny font
          scriptscriptstyle("Tiny")
        )
      )
    )
  )

subsubtitle

Notice how the lines are made to follow the same center. I'm not sure if that can be changed. Also, I don't know if it's possible to set each subtitle line's font size independently.

5 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.