forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot4.R
16 lines (14 loc) · 767 Bytes
/
plot4.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
library(dplyr)
source("loadData.R")
data <- load_data()
png("plot4.png", width=480,height=480)
par(mfrow=c(2,2))
plot(data$datetime, data$Global_active_power, type = "l", ylab="Global Active Power", xlab = "")
plot(data$datetime, data$Voltage, type = "l", ylab="Voltage", xlab = "datetime")
plot(data$datetime, data$Sub_metering_1, type = "l", ylab="Energy sub metering", xlab = "")
lines(data$datetime, data$Sub_metering_2, type = "l", col="red")
lines(data$datetime, data$Sub_metering_3, type = "l", col="blue")
legend("topright", legend=c("Sub_metering_1","Sub_metering_2","Sub_metering_3"), col=c("black","red","blue"), lty = 1)
plot(data$datetime, data$Global_reactive_power, type = "l", ylab="Global_reactive_power", xlab = "datetime")
dev.off()
rm(list=ls())