Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

How to Add Titles and Axis Labels to a Plot in R

You can easily add the main title and axis labels with arguments to the plot() function in R to enhance the quality of your graphic.

  • main: Main plot title

  • xlab: x-axis label

  • ylab: y-axis label

To add a title and axis labels to your plot of faithful, try the following:

image0.jpg
> plot(faithful,
+   main = "Eruptions of Old Faithful",
+   xlab = "Eruption time (min)",
+   ylab = "Waiting time to next eruption (min)")

R allows you to also take control of other elements of a plot, such as axes, legends, and text:

  • Axes: If you need to take full control of plot axes, use axis(). This function allows you to specify tickmark positions, labels, fonts, line types, and a variety of other options.

  • Legends: You can use the legend() function to add legends, or keys, to plots.

  • Text: In addition to legends, you can use the text() function to add text elements at any position on the plot.

The Help pages of the respective functions give you more information, and the examples contained in the Help pages show you how much you can do with these functions.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!