O'Reilly logo

R for Data Science by Dan Toomey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scatter plots

A scatter plot is a basic plotting device comparing datasets with two axes. A basic scatter plot is provided with the plot function built into the R system.

Note

Several objects available in R and packages have their own plot function in order to effectively portray the data associated.

The plot function looks as follows:

plot(x,
   y,
   type,
   main,
   sub,
   xlab,
   ylab,
   asp)

The various parameters of this function are described in the following table:

Parameter

Description

x

This is an independent variable.

y

This is a dependent variable.

type

This defines the type of plot. It should be one of the following types:

  • p for points
  • l for lines
  • b for both
  • c for the lines part alone of b
  • o for both overplotted
  • h for histogram-like (or high-density) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required