forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot3.R
28 lines (22 loc) · 1.03 KB
/
plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## plot3.R
## This is the script for the third plot of Project 1
# set time locale to display dates in English
Sys.setlocale(category = "LC_TIME", locale = "USA")
plot(hpc$DateTime, hpc$Sub_metering_3, type="n", xlab="",
ylim=c(0,38), ylab="Energy sub metering")
legend_lbl <- c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3")
legend_col <- c("black", "red", "blue")
legend("topright", legend=legend_lbl, col=legend_col, lty=1, cex=0.9)
lines(hpc$DateTime, hpc$Sub_metering_1)
lines(hpc$DateTime, hpc$Sub_metering_2, col="red")
lines(hpc$DateTime, hpc$Sub_metering_3, col="blue")
png(file="plot3.png")
plot(hpc$DateTime, hpc$Sub_metering_3, type="n", xlab="",
ylim=c(0,38), ylab="Energy sub metering")
legend_lbl <- c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3")
legend_col <- c("black", "red", "blue")
legend("topright", legend=legend_lbl, col=legend_col, lty=1, cex=0.9)
lines(hpc$DateTime, hpc$Sub_metering_1)
lines(hpc$DateTime, hpc$Sub_metering_2, col="red")
lines(hpc$DateTime, hpc$Sub_metering_3, col="blue")
dev.off()