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 (13 loc) · 699 Bytes
/
plot3.R
File metadata and controls
14 lines (13 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
png (file="plot3.png")
c <- read.table("household_power_consumption.txt",header=TRUE,sep=";")
c$Date <- as.Date(c$Date,"%d/%m/%Y")
cv <- c[c$Date == "2007-02-01" | c$Date =="2007-02-02",]
cv$DateTime <- paste(cv$Date,cv$Time)
cv$DateTime <- strptime(cv$DateTime, "%Y-%m-%d %H:%M:%S")
with (cv,{
plot(DateTime,as.numeric(as.character(Sub_metering_1)), type="l",ylab="Energy Sub Metering",xlab="")
points(DateTime,as.numeric(as.character(Sub_metering_2)), type="l",col="Red")
points(DateTime,as.numeric(as.character(Sub_metering_3)), type="l",col="Blue")
legend("topright",pch="--",col=c("black","blue","red"),legend=c("Sub_metering_1","Sub_metering_2","Sub_metering_3"))
})
dev.off()