πŸ“ˆGeneric Plot Types

The plot() function in R is the function to create the most basic type of plots.

A simplified format of the function is:

plot(x, y, type="p")

Here,

  • x and y: the coordinates of points to plot

  • type: the type of graph to create; Possible values are :

    • type=β€œp”: for points (by default)

    • type=β€œl”: for lines

    • type=β€œb”: for both; points are connected by a line

    • type=β€œo”: for both β€˜overplotted’;

    • type=β€œh”: for β€˜histogram’ like vertical lines

    • type=β€œs”: for stair steps

    • type=β€œn”: for no plotting

Example

# Data
x<-1:10; y=x**3

# Create different plots
plot(x,y, type="p")
plot(x,y, type="b")
plot(x,y, type="h")
plot(x,y, type="s")

Source:

Source of contents on this page: Generic plot types in R

Last updated