Categories:

Cloud (204)

Entertainment (11)

Facebook (43)

General (50)

Life (31)

Programming (64)

Technology (398)

Testing (4)

Tools (488)

Twitter (5)

Wearable (26)

Web Design (44)

Collections:

Other Resources:

What Is plot() Function

Q

How to use the plot() function to generate graphics?

✍: FYIcenter.com

A

plot() function allows you to generate a graph representing a given sequence of x-y points. plot() function is provided in the built-in "graphics" package.

plot() function takes the following positional arguments:

- p1 - x-coordinates of points. p1 could also be a data structures with 2 vectors/lists, which represents both x- and y-coordinates, or a function.
- p2 - optional, y-coordinates of points. If p1 is a function, p2 will be the starting value of the independent variable.
- p3 - optional, the ending value of the independent variable, if p1 is a function.

plot() function also takes 5 optional named arguments:

- type - type of graph to be generated, "p" for points, "l" for lines, "b" for both, "h" for histogram, "s" for stairs, etc.
- main - optional, text for the main title.
- sub - optional, text for the sub-title.
- xlab - optional, text for the x-axis label.
- ylab - optional, text for the y-axis label.
- asp - optional, aspect ratio of y- over x-axis.

Examples calling plot() function:

# coordinates specified as 2 vectors plot( c(1,2,3,4), c(31, 22, 13, 44) ) # coordinates specified as a data frame plot( c(1,2,3,4), c(31, 22, 13, 44) ) # coordinates specified as a function plot(sin, -pi, 2*pi)

2023-05-09, 342🔥, 0💬

Popular Posts:

Why the "dir" command hangs when using the FTP command-line tool on Windows? when you run the "dir" ...

Where does Mozilla Firefox 2 store download files? When you download files from Websites, Mozilla Fi...

Where to find answers to frequently asked questions on installing and using Mozilla Firefox 2.0? Her...

Where to find answers to frequently asked questions on FTP (File Transfer Protocol and related tools...

How to join a team in Microsoft Teams? My manager told me we are using Microsoft Teams service. In o...