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
51 lines (44 loc) · 1.18 KB
/
plot3.R
File metadata and controls
51 lines (44 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
####
#
# Author: Toby Patterson
# File: plot3.R
# Date: 7 August 2014
#
# Plots the relationship between days of week and various Energy sub metering.
# Presumes the file project1_datafile.Rda exists in the same directory.
#
####
# Read in the table data
# Note you may need to run generate_datafile.R if this file does not exist
data_file = 'project1_datafile.Rda'
if ( !file.exists(data_file)) {
stop('Run generate_datafile.R to create the project working datafile.')
}
# Output to file
canvas_size = 480
png(
file="plot3.png",
height = canvas_size,
width=canvas_size
)
plot(
data$DateTime,
data$Sub_metering_1,
#ylim=c(1,max(apply(data[,c("Sub_metering_1","Sub_metering_2","Sub_metering_3")], 2, max))),
ylab='Energy sub metering',
xlab='',
type='n'
)
# Plot points
points(data$DateTime,data$Sub_metering_1,col='black',type='l')
points(data$DateTime,data$Sub_metering_2,col='red',type='l')
points(data$DateTime,data$Sub_metering_3,col='blue',type='l')
legend("topright",
col=c("black", "red", "blue"),
c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"),
lty=1
)
# Yes I do want this
mtext('generated by Toby Patterson, 7 Sept 2014',1,4,cex=.5)
# Detatch
dev.off()