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
26 lines (20 loc) · 801 Bytes
/
Copy pathplot3.R
File metadata and controls
26 lines (20 loc) · 801 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
25
26
plot3 <- function(data){
figure_path <- "plot3.png"
# png default is 480x480
png(figure_path)
# Plot multiple graphs for Sub metering v/s Date time on single plot
plot(data$Date_time, data$Sub_metering_1, type='l', xlab="",
ylab="Energy sub metering")
lines(data$Date_time, data$Sub_metering_2, type='l', col='red')
lines(data$Date_time, data$Sub_metering_3, type='l', col='blue')
legend("topright", lty=1, col = c("black", "red", "blue"),
legend = c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"))
dev.off()
}
main <- function(data_path="data"){
# Assuming that the workspace points to the current directory
source("save_and_load_data.R")
data <- save_and_load_data(data_path)
plot3(data)
}
main()