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) · 727 Bytes
/
Copy pathplot3.R
File metadata and controls
10 lines (10 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
data <- read.csv("household_power_consumption.txt", sep = ";", na.strings=c("?"))
filtered_data <- data[data$Date == "1/2/2007" | data$Date == "2/2/2007",]
filtered_data$DateTime <- strptime(paste(filtered_data$Date, filtered_data$Time), format = "%d/%m/%Y %H:%M:%S")
png("plot3.png") ###width = 480, height=480
with(filtered_data, plot(DateTime, Sub_metering_1, type="n", ylab="Energy sub metering", xlab=""))
with(filtered_data, lines(DateTime, Sub_metering_1))
with(filtered_data, lines(DateTime, Sub_metering_2, col="red"))
with(filtered_data, lines(DateTime, Sub_metering_3, col="blue"))
legend("topright", c("Sub_metering_1","Sub_metering_2","Sub_metering_3"), col=c("black", "red", "blue"), lty = 1, lwd = 1)
dev.off()