Skip to content

Commit

Permalink
Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryHughes committed Nov 5, 2015
1 parent 73fe5c6 commit 7323e8d
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plot1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data <- read.table("household_power_consumption.txt", header = TRUE, sep = ";", na.strings = "?", colClasses = c("character", "character", "numeric"))
data <- subset(data, Date == "1/2/2007" | Date == "2/2/2007")
png(file = "plot1.png", width = 480, height = 480)
hist(data$Global_active_power, col = "red", xlab = "Global Active Power (kilowatts)", main = "Global Active Power")
dev.off()
Binary file added plot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions plot2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

data <- read.table("household_power_consumption.txt", header = TRUE, sep = ";", na.strings = "?", colClasses = c("character", "character", "numeric"))
data <- subset(data, Date == "1/2/2007" | Date == "2/2/2007")
png(file = "plot2.png", width = 480, height = 480)
plot(data$Global_active_power, type = "l", ylab = "Global Active Power (kilowatts)", xlab = "", xaxt = "n")
axis(1, c(0, nrow(data) / 2, nrow(data)), c("Thu", "Fri", "Sat"))
dev.off()
Binary file added plot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions plot3.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

data <- read.table("household_power_consumption.txt", header = TRUE, sep = ";", na.strings = "?", colClasses = c("character", "character", "numeric"))
data <- subset(data, Date == "1/2/2007" | Date == "2/2/2007")
png(file = "plot3.png", width = 480, height = 480)
plot(data$Sub_metering_1, type = "l", ylab = "Energy sub metering", xlab = "", xaxt = "n")
lines(data$Sub_metering_2, col = "red")
lines(data$Sub_metering_3, col = "blue")
axis(1, c(0, nrow(data) / 2, nrow(data)), c("Thu", "Fri", "Sat"))
legend("topright",
c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"),
lwd=c(2.5,2.5),
col = c("black", "red", "blue"))
dev.off()
Binary file added plot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions plot4.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

data <- read.table("household_power_consumption.txt", header = TRUE, sep = ";", na.strings = "?", colClasses = c("character", "character", "numeric"))
data <- subset(data, Date == "1/2/2007" | Date == "2/2/2007")
png(file = "plot4.png", width = 480, height = 480)

par(mfrow=c(2, 2))

plot(data$Global_active_power, type = "l", ylab = "Global Active Power", xlab = "", xaxt = "n")
axis(1, c(0, nrow(data) / 2, nrow(data)), c("Thu", "Fri", "Sat"))

plot(data$Voltage, type = "l", ylab = "Voltage", xlab = "datetime", xaxt = "n")
axis(1, c(0, nrow(data) / 2, nrow(data)), c("Thu", "Fri", "Sat"))

plot(data$Sub_metering_1, type = "l", ylab = "Energy sub metering", xlab = "", xaxt = "n")
lines(data$Sub_metering_2, col = "red")
lines(data$Sub_metering_3, col = "blue")
axis(1, c(0, nrow(data) / 2, nrow(data)), c("Thu", "Fri", "Sat"))
legend("topright",
c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"),
lwd=c(2.5,2.5),
col = c("black", "red", "blue"),
bty = "n")

plot(data$Global_reactive_power, type = "l", ylab = "Global_reactive_power", xlab = "datetime", xaxt = "n")
axis(1, c(0, nrow(data) / 2, nrow(data)), c("Thu", "Fri", "Sat"))

dev.off()
Binary file added plot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7323e8d

Please sign in to comment.