Figure 14-2: The Built-in Fonts

Portfolio Categories: All Graphics and SGR Book Graphics.

Demonstration of Built-in R Graphics Fonts

The Built-in R Graphics Fonts


# 14.2 Setting up fonts =================================================== 14.2

# 14.2a The built-in fonts =============================================== 14.2a
png(filename = "illustrations/fig-14-2-fonts.png",
  units = "in",                        # Set measurements in inches
  res = 1200,                          # Set resolution at 1200dpi
  width = 6,                           # Width at 6 inches
  height = 4)                          # Height at 4 inches

par(mfcol = c(2, 2))                   # Set 2x2 grid of plots
plot(myV1, myV2, type = "b",           # A simple plot
  main = "Family = 'sans'",            # A title 
  sub = "The default sans-serif font", # A subtitle
  family = "sans")                     # Set font family to sans

plot(myV1, myV2, type = "o",           # A simple plot
  main = "Family = 'serif'",           # A title 
  sub = "The serif font",              # A sub-title
  family = "serif")                    # Set font family to serif

plot(myV1, myV2, type = "l",           # A simple plot
  main = "Family = 'mono'",            # A title 
  sub = "The mono-spaced font",        # A sub-title
  family = "mono")                     # Set font family to mono

plot(myV1, myV2, type = "p",           # A simple plot
  main = "Variation in font styles",   # A title 
  sub = "Same font family, different styles and sizes",
  family = "serif",                    # Set font family to serif
  font.main = 4, cex.main = 1.75,      # Title in larger bold italic
  font.axis = 2, cex.axis = .75,       # Axis fonts small but bold
  font.sub = 3, cex.sub = .6,          # Subtitle fonts in italic & larger
  font.lab = 1, cex.lab = 1)           # Axis labels plain & default size
     
dev.off()                              # Output png file