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
25 lines (18 loc) · 667 Bytes
/
plot4.R
File metadata and controls
25 lines (18 loc) · 667 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
## load data
source("loadData.R")
data <- loadData()
## make plot
png("plot4.png")
par.old <- par()
par(mfrow = c(2, 2))
with(data, {
plot(datetime, Global_active_power, xlab = "", ylab = "Global Active Power(kilowatts)", type = "l")
plot(datetime, Voltage, type = "l")
plot(datetime, Sub_metering_1, xlab = "", ylab = "Energy sub metering", type = "l")
lines(datetime, Sub_metering_2, col = "red")
lines(datetime, Sub_metering_3, col = "blue")
legend("topright", col = c("black", "red", "blue"), lty = 1, bty = "n", legend = paste("Sub_metering", 1:3, sep = "_"))
plot(datetime, Global_reactive_power, type = "l")
})
par(par.old)
dev.off()