forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot3.R
30 lines (26 loc) · 1.24 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
29
30
plot3 <- function() {
# Get dataset path (download dataset if needed)
source("get_dataset.R")
dataset_path <- get_dataset()
# Get data of interest
source("get_data_of_interest.R")
data <- get_data_of_interest(dataset_path,
start_date = "01/02/2007 00:00:00",
end_date = "02/02/2007 23:59:00",
columns = c("Date","Time",
"Sub_metering_1",
"Sub_metering_2",
"Sub_metering_3"))
# display histogram on screen
ylab <- "Energy sub metering"
with(data,plot(x=DateTime, y= Sub_metering_1,type = "n",
xlab="", ylab=ylab))
with(data,lines(DateTime, Sub_metering_1, col = "black"))
with(data,lines(DateTime, Sub_metering_2, col = "red"))
with(data,lines(DateTime, Sub_metering_3, col = "blue"))
legend("topright", col = c("black", "red", "blue"),lty=c(1,1),
legend = c("Sub_metering_1", "Sub_metering_2","Sub_metering_3"))
# call copy2png to get the png file at the folders directory
source("dev.copy2png.R")
dev.copy2png("plot3.png")
}