[R language plot] use of the plot function, plot
The simplest plotting function in the R language is plot. If you have used matlab before, you may try to use the plot command when you use R to draw images. Plot (a) generally gets the graph we want. However, if you want to further set other attributes, such as the title, X axis name, and Y axis name, you also need to know some other parameters. The following is a simple example. After reading it, you can understand how to use the plot function.
Attach (mtcars) # obtain the data that comes with the system. mtcarsclass (mtcars) mtcarsmtcars <-mtcars [order (mtcars $ wt),] # To better display the results, sort data tables by wt columns from small to large # simple plot (mtcars $ mpg) plot (mtcars $ wt, mtcars $ mpg) # Set all available parameters (x = mtcars $ wt, y = mtcars $ mpg, type = "o", # linear main = "title ", sub = "subtitle", xlab = "x axis", ylab = "y axis", asp = 0.1) # y/x ratio, y axis value length to x axis value length ratio
In addition, you need to add other options for the type line type parameter.
Click "p" for points, line "l" for lines, point line "B" for both, and remove Point "c" for the lines part alone of "B ", covered Wire "o" for both 'overlotted', similar to the histogram "h" for 'histogram 'like (or 'high-density') vertical lines, stair-like "s" for stair steps, stair-like "S" for other steps, see 'details' below, no "n" for no ploy.
Result
Reference: help (plot)
Reprinted please indicate the source: http://blog.csdn.net/zhyoulun/article/details/46410123