forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
28 lines (23 loc) · 771 Bytes
/
plot2.R
File metadata and controls
28 lines (23 loc) · 771 Bytes
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
source("load.R")
# Helper function for drawing the plot
do_plot2 <- function(hpc,shortylab=FALSE){
if(shortylab==TRUE)
ylab="Global Active Power"
else
ylab="Global Active Power (kilowatts)"
plot(hpc$datetime,hpc$Global_active_power,type='l',ylab=ylab,xlab ="")
}
# Wrapper function for taking care of loading data, output device, ...
# This is what you should call to view the result
plot2 <- function(hpc=NULL){
# Load Plot data
if(is.null(hpc)){
hpc<-load_data()
}
# Create PNG output device
png("plot2.png",width = 480, height = 480)
# Draw plot
do_plot2(hpc)
# Release output device
dev.off()
}