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
21 lines (16 loc) · 701 Bytes
/
plot4.R
File metadata and controls
21 lines (16 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
source('read_data.R')
png(file="plot4.png", width=480, height=480)
par(mfrow=c(2,2), mar=c(5,5,1,1))
#1,1
plot(d$DateTime, d$Global_active_power, type="l", xlab="", ylab="Global Active Power" )
#1,2
with(d, plot(DateTime, Voltage, type="l", xlab="Datetime", ylab="Voltage"))
#1,3
plot(d$DateTime, d$Sub_metering_1, type="l", xlab="", ylab="Energy sub metering")
lines(d$DateTime, d$Sub_metering_2, type="l", col="red")
lines(d$DateTime, d$Sub_metering_3, type="l", col="blue")
legend("topright", legend=c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"),
lty=c(1,1,1), col=c("black", "red", "blue"), box.lwd=0)
#1,4
with(d, plot(DateTime, type="l", Global_reactive_power))
dev.off()