-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot4.R
More file actions
15 lines (15 loc) · 993 Bytes
/
plot4.R
File metadata and controls
15 lines (15 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
datasrc<-"I:/basam/Education/JHU DATA SCIENCE/exdata-data-household_power_consumption/household_power_consumption.txt"
data<-read.table(datasrc,header=TRUE,sep=";",stringsAsFactors = FALSE,dec=".")
subdata<-data[data$Date=="1/2/2007"|data$Date=="2/2/2007",]
globalReactivePower <- as.numeric(subdata$Global_reactive_power)
voltage <- as.numeric(subdata$Voltage)
png("plot4.png", width=480, height=480)
par(mfrow = c(2, 2))
plot(datetime, globalActivePower, type="l", xlab="", ylab="Global Active Power", cex=0.2)
plot(datetime, voltage, type="l", xlab="datetime", ylab="Voltage")
plot(datetime, subMetering1, type="l", ylab="Energy Submetering", xlab="")
lines(datetime, subMetering2, type="l", col="red")
lines(datetime, subMetering3, type="l", col="blue")
legend("topright", c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"), lty=, lwd=2.5, col=c("black", "red", "blue"), bty="o")
plot(datetime, globalReactivePower, type="l", xlab="datetime", ylab="Global_reactive_power")
dev.off()