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
24 lines (17 loc) · 825 Bytes
/
plot3.R
File metadata and controls
24 lines (17 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
source("loadData.R")
source("savePlot.R")
pkgTest("lubridate")
# load the household data
householData <- loadData("household_power_consumption.txt")
# convert to date and to time, then concatenate, creating a datetime field
householData$DateTime <- dmy(householData$Date) + hms(householData$Time)
# plot!
plot(householData$DateTime, householData$Sub_metering_1, type = 'l', xlab = "Energy sub metering", ylab = "")
# add submetering2 line
lines(householData$DateTime, householData$Sub_metering_2, col = "red")
# add submetering3 line
lines(householData$DateTime, householData$Sub_metering_3, col = "blue")
# add the legend
legend('topright',legend=c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"), col=c("black","red","blue"), lty='solid', cex=0.75, x.intersp=0.1, y.intersp = 0.8)
# save!
savePlot("plot3.png")