R Language Drawing Curve

Source: Internet
Author: User

This paper takes the fire statistics of our country from 1950 to 2010 as an example, the data are as follows:

(0) Loading data

Data<-read.csv ("e:\\mydocument\\p\\data\\1950~2010 fire situation. csv")

X=t (Data[1])

Y=t (Data[2])

Z=t (Data[3])

W=t (Data[4])

Maxy=max (y)

Maxz=max (z)

Maxw=max (W)

(1) The number of fires, direct losses, casualties, respectively, according to the year of drawing

plot (x,y,type= "O", xlab= "year", ylab= "Fire (UP)", Ylim=c (0,maxy), col= "Red", main= "1950 to 2010 Fire Annual Statistics", Pch=c ()

plot (x,z,type= "O", xlab= "year", ylab= "economic loss (million)", Ylim=c (0,MAXZ), col= "Blue", main= "annual statistics of Fire economic losses from 1950 to 2010", Pch=c ( ))

Plot (x,w,type= "O", xlab= "year", ylab= "casualties", Ylim=c (0,MAXW), col= "Green", main= "annual statistics of Fire casualties from 1950 to 2010", Pch=c (17))

Note: x, y and y axes are shown in the graph, type sets the display type of the data in the graph, and the common ones are:

Type= "P" shows the data as a point in the graph;

Type= "L" in the graph data display as a line;

Type= "B" shows the data as points and connectors in the graph;

Type= "O" in the graph data points overlay online;

Type= "H" shows the data in the graph as a vertical line from point to X axis;

Type= "S" in the graph data display as a ladder diagram;

Type= "n" data is not displayed in the graph;

Xlab and Ylab respectively represent the x-axis and y-axis descriptions, Ylim to control the range of the y-axis, col as the color of the line, main as the main title of the graph, the PCH for the display of the number of points, the 1 to 25 integer and the symbol in the "":

(2) The number of fires, direct losses, casualties are drawn in a picture

> Plot (x,y,type= "O", xlab= "year", ylab= "", Ylim=c (0,maxy), col= "Red", main= "1950 to 2010 Fire Annual Statistics", Pch=c ()) #画火灾数曲线

> Lines (x,z,type= "O", col= "Blue", pch=c (+)) #追加经济损失曲线 > lines (x,w,type= "O", col= "green", pch=c (+)) #追加死伤人数曲线

(3) Add column

Legend ("TopLeft", C ("Fire (UP)", "economic loss (million)", "casualties"), Col=c ("Red", "Blue", "green"), pch=15:17)

R Language Drawing Curve

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.