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
18 lines (16 loc) · 775 Bytes
/
Copy pathplot3.R
File metadata and controls
18 lines (16 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
plot3 <- function(){
data<-subset(read.table("household_power_consumption.txt", header=TRUE,
sep=";", na.strings="?"),
Date=="1/2/2007"|Date=="2/2/2007")
data$T<-strptime(paste(data$Date,data$Time),"%d/%m/%Y %H:%M:%S")
data$wday<-format(data$T,"%a")
par(mfrow=c(1,1))
plot(data$T,data$Sub_metering_1,type="l",xlab="",
ylab="Energy sub metering")
lines(data$T,data$Sub_metering_2,col="red")
lines(data$T,data$Sub_metering_3,col="blue")
legend("topright",legend=c("Sub_metering_1","Sub_metering_2","Sub_metering_3"),
col=c("black","red","blue"),lty=1)
dev.copy(png, file="plot3.png")
dev.off()
}