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
13 lines (12 loc) · 883 Bytes
/
Copy pathplot3.R
File metadata and controls
13 lines (12 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
fileName="household_power_consumption.txt"
data5row <- read.table(fileName, header = TRUE, nrows = 5, sep=';', stringsAsFactors=FALSE)
classes <- sapply(data5row, class)
data <- read.table(fileName, header = TRUE, colClasses = classes, sep=';', na.strings = "?")
sdata <- data[data$Date %in% c("1/2/2007", "2/2/2007"),]
sdata$DateTime<-strptime(paste (sdata$Date, sdata$Time), format = "%d/%m/%Y %H:%M:%S" )
png(file = "plot3.png", width = 480, height = 480, units = "px", pointsize = 12, bg = "white")
plot(sdata$DateTime, sdata$Sub_metering_1,type="l",col="black",xlab="", ylab="Energy sub metering",font.lab = 2,lwd=1)
lines(sdata$DateTime, sdata$Sub_metering_2,type="l",col="red")
lines(sdata$DateTime, sdata$Sub_metering_3,type="l",col="blue")
legend('topright', c('Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3') , lty=1, col=c('black', 'red', 'blue'), cex=.9)
dev.off()