# 14.3 Titles and Subtitles =============================================== 14.3
# Short example of using text variables for title
myTitle = "My Nice Title" # Create a txt variable with title
plot(myX, myY, main = myTitle) # Plot using txt variable title
png(filename = "illustrations/fig-14-5-Title and subtitle-BW.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
plot(myV1, myV2, type = "l", # A simple plot
main = "Here is the title", # The main title
family = "serif", # Use serif family font
font.main = 2, # Set title font to bold
cex.main = 3, # Set title font size to double
col.main = "darkgray", # Set title to dark gray
xlab = NA, ylab = NA) # Supress axis labels
title( # Put subtitle on plot
sub = "This is the subtitle", # A subtitle
adj = 1, # Put it on right side
family = "mono", # Use mono-spaced font
font.sub = 2, # Use bold for subtitle
cex.sub = 1.5, # Subtitle font size = 1.5
col.sub = "black") # Subtitle color
title( # Put X axis label on plot
xlab = "This is the x-axis label", # X axis label text
family = "sans", # Use sans-serif font
font.lab = 3, # Use italic for x axis label
cex.lab = 1.25, # X-axis label font size
col.lab = "darkgray") # X-axis label color
title( # Put Y axis label on plot
ylab = "Y is here", # Y axis label text
family = "serif", # Use serif font
font.lab = 2, # Use bold for y axis label
cex.lab = 1.25, # Y-axis font size = 1.25
col.lab = "darkgray", # Y-axis label color
las = 2)
dev.off() # Output png file
Figure 14-5: Titles and Subtitles
Portfolio Categories: All Graphics and SGR Book Graphics.