Adding Labels and Titles
In this page:
Adding Labels and Titles
Plot functions accept main for a title, xlab/ylab for axis labels, and col for color, all directly as arguments. Clear labeling turns a raw plot into something a reader can actually interpret without guessing what the axes represent. Well-labeled plots are a basic requirement for any chart meant to be shared or published.
Note: Always set main, xlab, and ylab -- an unlabeled plot is nearly useless to anyone besides the person who made it.
Example: Adding Labels and Titles
x <- 1:5
y <- c(2, 4, 6, 8, 10)
cat("plot(x, y, main='Growth', xlab='Time', ylab='Value', col='blue')\n")
cat("would draw a labeled scatter plot titled 'Growth'\n")
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: