forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot4.R
30 lines (20 loc) · 1.07 KB
/
plot4.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
# Please make sure that the "Read_Data.R" file is also in your R working repository
source('Read_Data.R')
png('plot4.png')
par(mfcol=c(2,2),pty='m')
#---- Draw Top Left plot ------------------------------------
with(dat, plot(DateTime,Global_active_power, type="l",
xlab="",ylab="Global Active Power"))
#---- Draw Lower Left plot ------------------------------------
with(dat, plot(DateTime,Sub_metering_1, type="l", col="black", xlab="",ylab="Energy sub metering"))
with(dat,points(DateTime,Sub_metering_2, type="l", col="red"))
with(dat,points(DateTime,Sub_metering_3, type="l", col="blue"))
legend('topright',lty='solid',col=c('black','red','blue'), bty='n',
legend=c('Sub_metering_1','Sub_metering_2','Sub_metering_3'))
#---- Draw Top Right plot ------------------------------------
with(dat, plot(DateTime,Voltage, type="l",
xlab="datetime",ylab="Voltage"))
#---- Draw Lower Right plot ------------------------------------
with(dat, plot(DateTime,Global_reactive_power, type="l",
xlab="datetime",ylab="Global_reactive_power"))
dev.off()