📈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