forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot3.R
21 lines (17 loc) · 754 Bytes
/
plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# This script renders the third plot
# remove all variables from the workspace
rm(list = ls())
# set the work directory
setwd("C:/Users/Rod/Documents/coursera/data-science/04_ExploratoryDataAnalysis/02-second-try/week_01/project/ExData_Plotting1")
# Import getData function
source('util.R')
message('Printing plot 3...')
data <- getData()
png('output/plot3.png', width=480, height=480, bg='transparent')
with(data, {
plot(DateTime, Sub_metering_1, type='l', xlab='', ylab="Energy sub metering")
lines(DateTime, Sub_metering_2, type='l', col='red')
lines(DateTime, Sub_metering_3, type='l', col='blue')
})
legend('topright', legend=c('Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3'), lwd='1', col=c('black', 'red', 'blue'))
dev.off()