forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot4.R
60 lines (50 loc) · 824 Bytes
/
plot4.R
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
source("prep.R")
png("plot4.png", width = 480, height = 480)
# plot in 2x2 grid
par(mfcol=c(2,2))
#1
plot(
data$DateTime,
data$Global_active_power,
type="l",
lwd=1,
ylab="Global Active Power",
xlab="")
#2
plot(
data$DateTime,
sub$Sub_metering_1,
type="l",
ylab="Energy sub metering",
xlab="")
lines(
data$DateTime,
data$Sub_metering_2,
type="l",
col="red")
lines(
data$DateTime,
data$Sub_metering_3,
type="l",
col="blue")
legend(
"topright",
c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"),
lty=1,
bty="n",
col=c("black", "red", "blue"))
#3
plot(
data$DateTime,
data$Voltage,
type="l",
xlab="datetime",
ylab="Voltage")
#4
plot(
data$DateTime,
data$Global_reactive_power,
type="l",
xlab="datetime",
ylab="Global_reactive_power")
dev.off()