forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot3.R
17 lines (15 loc) · 744 Bytes
/
plot3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
library(dplyr)
dat <- read.csv('household_power_consumption.txt', sep=';',
na.strings = '?')
fil_dat <- filter(dat, dat$Date == '1/2/2007' | dat$Date == '2/2/2007')
fil_dat$datetime <- strptime(paste(fil_dat$Date, fil_dat$Time), '%d/%m/%Y %T')
png(filename='plot3.png', width=480, height=480)
with(fil_dat, plot(datetime, Sub_metering_1, type='n',
ylab='Energy sub metering',
xlab=''))
with(fil_dat, lines(datetime, Sub_metering_1))
with(fil_dat, lines(datetime, Sub_metering_2, col='red'))
with(fil_dat, lines(datetime, Sub_metering_3, col='blue'))
legend('topright', lty=1, col=c('black', 'red', 'blue'),
legend=c('Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3'))
dev.off()