forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot4.R
15 lines (14 loc) · 952 Bytes
/
plot4.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#Code for constructs the plot 4, with call to the code to read data and code for creating the PNG file
source('readData.R')
png('plot4.png', width=480, height=480)
par(mfrow = c(2,2))
with(cons_subset, {
plot(cons_subset$Global_active_power ~ cons_subset$DateTime , xlab='', ylab="Global Active Power", type='l', col="black")
plot(cons_subset$Voltage ~ cons_subset$DateTime , xlab='datetime', ylab="Voltage", type='l', col="black")
plot(Sub_metering_1 ~ DateTime , xlab='', ylab="Energy sub metering", type='l', col="black")
lines(Sub_metering_2 ~ DateTime , xlab='', type='l', col="red")
lines(Sub_metering_3 ~ DateTime , xlab='', type='l', col="blue")
legend("topright", lty=1, col = c("black", "red","blue"), legend = c("Sub_metering_1", "Sub_metering_2","Sub_metering_3"), bty='n')
plot(cons_subset$Global_reactive_power ~ cons_subset$DateTime , xlab='datetime', ylab="Global_reactive_power", type='l', col="black")
})
dev.off()