R-plot ()

Source: Internet
Author: User
Tags numeric
General scatter Plot:
> BOD Time
  demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
> Plot (bod$time,bod$demand,main= ' main title ', xlab= ' x axis title ', Ylab = ' Y axis title ', Xlim=c (0,10), Ylim=c (8,20), col= ' Blue ', pch=19)

notes: Bod$time,bod$demand: Takes the time and demand columns in the BOD data frame as the x and Y axes. Main: The caption of the graph. Labels for the xlab,ylab:x and y axes. The range of values for the xlim,ylim:x axis and y-axis. Col: The color of a data point, which can be a color character or a numeric code of a color. PCH: The shape of a data point, which can be a number between 0~25, or a character, such as ' * '. CeX: The size of the data point. Axes:f or T, whether the x-axis and y-axis are displayed, and the default is T.

Frame.plot=f: The box is not displayed.

Type parameter: Type= ' P ': Only scatter points are displayed. Type= ' l ': Show only lines. Type= ' B ': Show Scatter and lines. Type= ' C ': shows the lines that remove the scatter. Type= ' O ': Displays the line through the point. Type= ' h ': Displays the vertical lines of each scatter point to the x-axis. Scatter Atlas:

> Plot (Iris[,1:4])

Equivalent to:

> Pairs (Iris[,1:4])

It is convenient to see whether there is a normal distribution between the attributes. Multivariate scatter plot:

>i = As.numeric (iris$species)
>i
 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [49] 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 [$] 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
[ 145] 3 3 3 3 3 3
>plot (iris[,1],iris[,4],pch=i,col=i)
>legend (' BottomRight ', C (' Setosa ', ' versicolor ', ' Virginica '), Pch=c (Col=c),

notes:

1, iris$species store flower varieties, is a character type, with As.numeric () converted into digital type.
2, Legend () add the lower right corner of the legend, the specific use of detailed after the completion. three-dimensional scatter plot:

>library (Scatterplot3d)
>scatterplot3d (iris[,1:3],color= ' Blue ', x.ticklabs=c (' good ', ' put ', ' for ', ' and ', ' out '), BOX=T)

Note: to download and install the Scatterplot3d package before using Scatterplot3d. The color of the data points in three dimensions is not used for Col. X.ticklabs () To change the label of the x-axis. box is a logical T or F that indicates whether a border is displayed, and the default is T. The grid is a logical t or F, which represents the X-and y-axis plane, which is the existence of the mesh table, which defaults to T. PCH, Main, Xlab, Ylab, Zlab, Xlim and other parameters are used as two-dimensional scatter plots.





PS: For the first time with markdown, it feels convenient to use, much better than HTML. But change the font, change the size of the picture is a bit more trouble, I hope to adapt as soon as possible, can write a more beautiful layout.


Reprint Please indicate the source, thank you. (Original link: http://blog.csdn.net/bone_ace/article/details/45071839)

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.