-
Notifications
You must be signed in to change notification settings - Fork 20
/
halloween.2015.R
44 lines (38 loc) · 2.39 KB
/
halloween.2015.R
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
library(scales)
times = c("5:30","5:45","6:00","6:15","6:30","6:45","7:00","7:15","7:30","7:45","8:00","8:15", "8:30")
counts = c(0,1,1,3,3,32,6,9,16,2,6,0,4)
Snickers = c(0,0,0,0,0,3,4,5,5,5,6,6,9)
BabyRuth = c(0,1,1,1,1,3,3,3,5,5,6,6,7)
MnMs.chocolate = c(0,0,0,1,2,9,11,14,14,14,15)
MnMs.peanut = c(0,0,0,0,0,2,2,3,3,3,4,4,5)
Twix = c(0,0,0,0,1,8,10,10,14,15)
Crunch = c(0,0,1,2,2,9,10,12,18,19,20)
Butterfinger = c(0,0,0,0,1,4,4,6,12,12,13,13,14)
png("halloween.2015.candy.png", res=150, width=700, height=400)
par(mai=c(0.5,0.5,0.1,1), cex.axis=0.6, xpd=NA)
plot(x=seq(length(times)), y=rep(0,length(times)), ylim=c(0,20), type="n", axes=FALSE, xlab="", ylab="")
axis(1, at=seq(length(times)), labels=times, tick=FALSE, pos=2)
axis(2, at=seq(0,20,5), las=2, tick=FALSE, pos=1.25)
mtext("cumulative pieces taken", side=2, line=1.25, cex=2/3)
segments(x0=rep(1,length(times)), x1=rep(length(times), length(times)), y0=seq(0,20,5), y1=seq(0,20,5), lwd=1, col="gray75")
lines(seq(length(Snickers)), Snickers, lwd=2, col=alpha("chocolate3", 2/3))
text(x=length(Snickers), y=Snickers[length(Snickers)], "Snickers", cex=2/3, pos=4)
lines(seq(length(Crunch)), Crunch, lwd=2, col=alpha("navy", 2/3))
text(x=length(Crunch), y=Crunch[length(Crunch)], "Nestle Crunch", cex=2/3, pos=4)
lines(seq(length(Butterfinger)), Butterfinger, lwd=2, col=alpha("goldenrod2", 2/3))
text(x=length(Butterfinger), y=Butterfinger[length(Butterfinger)], "Butterfinger", cex=2/3, pos=4)
lines(seq(length(Twix)), Twix, lwd=2, col=alpha("gold2", 2/3))
text(x=length(Twix), y=(Twix[length(Twix)]+1), "Twix", cex=2/3, pos=4)
lines(seq(length(MnMs.chocolate)), MnMs.chocolate, lwd=2, col=alpha("brown", 2/3))
text(x=length(MnMs.chocolate), y=MnMs.chocolate[length(MnMs.chocolate)], "Chocolate M&Ms", cex=2/3, pos=4)
lines(seq(length(MnMs.peanut)), MnMs.peanut, lwd=2, col=alpha("yellow2", 2/3))
text(x=length(MnMs.peanut), y=MnMs.peanut[length(MnMs.peanut)], "Peanut M&Ms", cex=2/3, pos=4)
lines(seq(length(BabyRuth)), BabyRuth, lwd=2, col=alpha("red", 2/3))
text(x=length(BabyRuth), y=BabyRuth[length(BabyRuth)], "Baby Ruth", cex=2/3, pos=4)
dev.off()
png(file="trickortreat.2015.png", width=700, height=300, bg="white")
par(mai=c(0.5,0.5,0.25,0.25))
barplot(counts, col = "orange", border = NA, names.arg = times, axes = FALSE, ylim=c(0,35))
axis(2, at=seq(0,35,5), tick=FALSE, las=2, pos = 1/2)
mtext("count of kids who came to our door", side=2, line=1)
dev.off()