forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot3.R
13 lines (11 loc) · 803 Bytes
/
plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
library(data.table)
setwd("~/RHome/data/Project1")
dataset <- read.table(file="household_power_consumption.txt",header=TRUE,sep=";",na.strings="?")
inscope_data <- dataset[as.character(dataset$Date) %in% c('2/2/2007','1/2/2007'),]
inscope_data$DateTime <- strptime(paste(inscope_data$Date,inscope_data$Time),format="%d/%m/%Y %H:%M:%S")
png(filename="plot3.png",width=480,height=480,units="px",bg=NA)
plot(x=inscope_data$DateTime,y=inscope_data$Sub_metering_1,type="l",col="black",xlab="",ylab="Energy sub metering")+
lines(x=inscope_data$DateTime,y=inscope_data$Sub_metering_2,type="l",col="red")
lines(x=inscope_data$DateTime,y=inscope_data$Sub_metering_3,type="l",col="blue")
legend("topright",legend=c('Sub_metering_1','Sub_metering_2','Sub_metering_3'),lwd=1,col=c("black","red","blue"))
dev.off()