forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot3.R
20 lines (16 loc) · 780 Bytes
/
plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
source("helpers.R")
# Set png with and height to 480px
png("plot3.png", width=480, height=480)
global_active_power = as.numeric(dataset$Global_active_power)
# Initiate variable to print
datetime <- strptime(paste(dataset$Date, dataset$Time, sep=" "), "%d/%m/%Y %H:%M:%S")
sub_metering1 <- as.numeric(dataset$Sub_metering_1)
sub_metering2 <- as.numeric(dataset$Sub_metering_2)
sub_metering3 <- as.numeric(dataset$Sub_metering_3)
# Build plot
plot(datetime, sub_metering1, type="l", ylab="Energy Submetering", xlab="")
lines(datetime, sub_metering2, type="l", col="red")
lines(datetime, sub_metering3, type="l", col="blue")
legend("topright", c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"), lty=1, lwd=2.5, col=c("black", "red", "blue"))
# Print plot to file
dev.off()