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
35 lines (24 loc) · 1002 Bytes
/
plot4.R
File metadata and controls
35 lines (24 loc) · 1002 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
source('utils.R')
plot4 <- function(){
p("Running plot4")
ds <- getData()
# Plot to png
png('plot4.png', width=480, height=480, bg='transparent')
# Adding plots in col-wised manner
par (mfrow = c(2,2))
with(ds, {
# 4.1 : Global Active Power plot
plot(DateTime, Global_active_power, xlab="", ylab="Global Active Power", type="l")
# 4.2 : Voltage Plot
plot(DateTime, Voltage, xlab="datetime", ylab="Voltage", type="l")
# 4.3 : Energy sub metering
plot(DateTime, Sub_metering_1, type="l", xlab="", ylab="Energy sub metering")
lines(DateTime, Sub_metering_2, type="l", col="red")
lines(DateTime, Sub_metering_3, type="l", col="blue")
legend('topright', legend=c('Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3'), lwd='1', col=c('black', 'red', 'blue'))
# 4.4 : Global reactive power
plot(DateTime, Global_reactive_power, xlab="datetime", ylab="Global_reactive_power", type="l")
})
dev.off()
}
plot4()