forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.R
More file actions
10 lines (10 loc) · 672 Bytes
/
plot3.R
File metadata and controls
10 lines (10 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
unzip("household_power_consumption.zip")
data <- read.table("household_power_consumption.txt", sep = ";", dec = ".", header = TRUE, stringsAsFactors=FALSE)
data <- rbind(data[which(data$Date == "1/2/2007"),], data[which(data$Date == "2/2/2007"),])
datetime <- strptime(paste(data$Date , data$Time), "%d/%m/%Y %H:%M:%S")
png(filename = "plot3.png", width = 480, height = 480)
plot(datetime, data[,7], type = "l", ylab = "Energy sub metering", xlab = " ")
lines(datetime, data[,8], col = "red")
lines(datetime, data[,9], 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"))
dev.off()