forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot4.R
More file actions
29 lines (19 loc) · 1.1 KB
/
plot4.R
File metadata and controls
29 lines (19 loc) · 1.1 KB
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
source( "assignmentLibrary.R" )
targetFile <- "plot4.png"
# start by initializing the data and directories (from assignmentLibrary.R)
initializeData()
# Open the PNG file for writing
openTarget( targetFile )
# this will be a 2 x 2 with 4 total graphs.
par( mfrow = c( 2, 2 ) )
plot( rawData$TimeStamp , rawData$Global_active_power, type = "l", xlab = "", ylab = "Global Active Power" )
plot( rawData$TimeStamp , rawData$Voltage, type = "l", xlab = "datetime", ylab = "Voltage" )
plot( rawData$TimeStamp , rawData$Sub_metering_1, type = "l", col = "black", xlab = "", ylab = "Energy sub metering" )
points( rawData$TimeStamp , rawData$Sub_metering_2, type = "l", col = "red" )
points( rawData$TimeStamp , rawData$Sub_metering_3, type = "l", col = "blue" )
legend( "topright", cex = .95, bty = "n", lwd = 1.0, col = c( "black", "red", "blue" ), legend = c( "Sub_metering_1", "Sub_metering_2", "Sub_metering_3" ) )
plot( rawData$TimeStamp , rawData$Global_reactive_power, type = "l", xlab = "datetime", ylab = "Global_reactive_power" )
# close the device
dev.off()
## reset the plotter to a 1x1 grid
par( mfrow = c( 1, 1 ) )