[R language plot] use of the plot function, plot

Source: Internet
Author: User

[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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.