Getting Started with the ggplot2 Package

Overview of the base graphics package in R

The base graphics package is contained in the graphics package distributed in base R. These are often used for creating data graphics, and the system provides many global parameters that can be set and manipulated to create a data chart. Let’s quickly understand how to create plots using the base graphics package before introducing the ggplot2 package. The base graphics package in R offers several high-level functions, such as:

  • plot(): This is a generic function that can plot a variety of plots.
  • boxplot(): This creates single and side-by-side boxplots.
  • hist(): This function creates histograms.
  • qqplot(), qqnorm(), and qqline(): These functions build quantile plots.
  • dotchart() and stripchart(): These functions are for creating dot plots.
  • image(), contour(), and persp(): These functions create 3D plots.
  • pairs(): This function plots scatter plot matrices.

Additionally, we can find simple functions like lines(), plots(), symbols(), arrows(), and many more in the base graphics package for creating data visualizations.

Now, let’s try a few examples to understand how data visualizations can be created using the base graphics package.

First, we’ll prepare a dataset with random numbers using the following code:

Create a free account to view this lesson.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy