forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot3.R
More file actions
14 lines (14 loc) · 693 Bytes
/
plot3.R
File metadata and controls
14 lines (14 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
df <- read.table('household_power_consumption.txt', nrow = 2880, sep = ';', h = F, skip = 66637)
NameDf <- readLines('household_power_consumption.txt', n = 1)
names(df) <- unlist(strsplit(NameDf,';'))
png('plot3.png', width = 480, height = 480)
plot(df$Sub_metering_1, type = "n", axes = F, xlab = "", ylab = "Energy sub metering")
lines(df$Sub_metering_1, col = "black")
lines(df$Sub_metering_2, col = "red")
lines(df$Sub_metering_3, col = "blue")
legend("topright", legend = c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"),
col = c("black", "red", "blue"), lty = c(1, 1, 1))
axis(1, c(0, 1440, 2880), labels = c("Thu", "Fri", "Sat"))
axis(2, c(0, 10, 20, 30))
box()
dev.off()