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
14 lines (10 loc) · 664 Bytes
/
plot3.R
File metadata and controls
14 lines (10 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
data <- read.table('household_power_consumption.txt', header = T, sep=";")
data$CorrectedTime <- as.POSIXct(paste(data[,'Date'], data[,'Time']), format = "%Y-%m-%d %H:%M:%S")
png(file = "plot3.png")
with(data,{plot(CorrectedTime, Sub_metering_1, type = "n", ylim = c(0,40), ylab= "Energy sub metering", xlab = "")
lines(CorrectedTime, Sub_metering_1, col = 'black')
lines(CorrectedTime, Sub_metering_2, col = 'red')
lines(CorrectedTime, Sub_metering_3, col = 'blue')
})
legend("topright", col = c('black','blue','red'), pch = '-', legend = c('Sub_metering_1', 'Sub_metering_2','Sub_metering_3') )
dev.off()