forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot4.R
More file actions
39 lines (28 loc) · 999 Bytes
/
plot4.R
File metadata and controls
39 lines (28 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
source("~/Loadfile.R")
##making plot in .png file.
png(filename = "plot4.png",
width = 480,height = 480,
units = "px",bg="transparent")
##fixing parameter to form layout for plot
par(mfrow=c(2,2))
##plot in top left
plot(DateTime, Global_active_power,
xlab = "",ylab = "Global Active Power",
main="",type = "l")
##plot in top right
plot(DateTime,Voltage, type = "l",
xlab = "datetime",ylab = "Voltage")
##plot in bottom left
plot(DateTime,Sub_metering_1,type = "l",
col="black",xlab = "",ylab = "Energy sub metering",
main = "")
lines(DateTime,Sub_metering_2,col="red")
lines(DateTime,Sub_metering_3,col="blue")
##remove boder of legend by using bty="n"
legend("topright",bty = "n",lty= 1,
lwd = 1,col=c("black","red","blue"),
legend = c("Sub_metering_1","Sub_metering_2","Sub_metering_3"))
##plot in bottom right
plot(DateTime,Global_reactive_power,type = "l",col="black",
xlab = "datetime",ylab = "Global_reactive_power")
dev.off()