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
23 lines (17 loc) · 917 Bytes
/
plot3.R
File metadata and controls
23 lines (17 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Read the data.
# Note: the code for loading the dataset would be repetitive
# and hard to maintain if copied, so it is sourced from a
# separate file (which is of course in the repo)
source('load_dataset_for_plotting_1.R')
# background transparent (as in Roger Peng's repo)
png('plot3.png', width=480, height=480, bg="transparent")
plot(x=dataset$DateTime, y=dataset$Sub_metering_1, type="l",
xlab="", ylab="Energy sub metering")
lines(x=dataset$DateTime, y=dataset$Sub_metering_2, col="red")
lines(x=dataset$DateTime, y=dataset$Sub_metering_3, col="blue")
legend("topright", c("Sub_metering_1","Sub_metering_2","Sub_metering_3"),
lty=c(1,1,1), col=c("black", "red", "blue"))
dev.off()
# NOTE: if you are running this on a 'non-english' computer, setting the locale
# might be necessary to get correct X-labels, e.g. on Ubuntu Linux use:
# Sys.setlocale("LC_TIME", "en_US.UTF8")