← Back to R Course | Chapter 10: Data Visualization | Lesson 7 of 7

Adding Labels and Titles

In this page:

  1. Adding Labels and Titles

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

markup
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")
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.