Halloween 2011 count

We don’t get many kids seeking candy at our house. I’m not sure if there just aren’t many kids in the neighborhood, or if it’s our location (next to the pond, with a big gap before the next house).

I decided to keep track. As usual, we bought a huge bag of candy, and we still had about half of it left to hand out tonight. But only 19 kids came.

They arrived pretty regularly from 5:50 to 7:50.

I comment on the figure’s style below.

In the above graph, I’m applying ideas learned from Dan Carr when I visited the statistics department at George Mason in September, to give a seminar. (I had a great time at GMU, particularly talking to Dan about graphics. I had a copy of his book about micromaps on my iPad, but hadn’t really looked at it until after I met him. Take a look at the first chapter; it’s full of good ideas and may convince you to read the rest.)

  • The gray background makes the figure stand out on the “page”. (I had disliked this aspect of ggplot2 plots (for example, this one), but Dan convinced me that it’s better.)
  • The black border around the figure is important. (Dan pointed out that it’s not the gray background I dislike about the default ggplot2 plots, but the lack of the border.)
  • The white grid lines make it easy to see the details, and they still don’t get in the way of the plot.
  • With the grid lines, you don’t need to include tick marks, but can just use proximity. (Note that the labels can and should be closer to the plot when there are no bristles ticks.)
  • The use of color for the actual data makes them stand out better.

Update: The code I used for the figure is here. It’s old-fashioned and inefficient, but it works.

Tags: , , ,

8 Responses to “Halloween 2011 count”

  1. Datatata Says:

    Good observation about the gray backgound. How to make the black border in ggplot2?

    • Karl Broman Says:

      I’ve added a link to my code. I didn’t use ggplot2 (still just intending to learn the system).

      • Datatata Says:

        So, it was my wrong consideration that grey background = ggplot2.

        Thanks for your code. I tried to think how to do the same with ggplot2 and it ended with the following


        x <- structure(list(time = structure(1:11, .Label = c("5:50", "6:10",
        "6:24", "6:31", "6:36", "6:56", "7:07", "7:21", "7:33", "7:46",
        "7:51"), class = "factor"), n.kids = c(2L, 2L, 1L, 2L, 1L, 2L,
        2L, 2L, 1L, 2L, 2L)), .Names = c("time", "n.kids"), class = "data.frame", row.names = c(NA,

        x$time <- strptime(x$time, "%H:%M")
        x$cumsum <- cumsum(x$n.kids)

        # step function data frame
        time.range <- strptime(c("04:00", "08:00"), "%H:%M")
        df <- data.frame(time=c(time.range[1], rep(x$time, each=2), time.range[2]),
        g=gl(nrow(x)+1,2), # grouping to lines
        p=c(FALSE, FALSE, 1:(2*nrow(x))%%2 == 1) # points

        # black border around the figure
        theme_update(panel.background = theme_rect(fill = "grey90", colour = "black"))

        ggplot(NULL, aes(time, cumsum)) +
        geom_point(data = df[df$p,], col="blue") +
        geom_line(aes(group= g), col="blue", data = df) +
        scale_y_continuous(limits=c(0,20)) +
        ylab("Cumulative number of kids") +

  2. andrew clark Says:

    I doled out 90 candies (with metaphorical slapped wrist if a kid tried to take more than 1) in 80 minutes before blacking out house and retiring to back room

  3. Nathalie Says:

    Funny data: I’m going to use them for my next statistics exam in January 😉

  4. Halloween 2016 count | The stupidest thing... Says:

    […] Here’s a graph of the numbers of trick-or-treat-ers we saw this evening, by time. 10 of the 25 kids arrived in one big group. (Compare this to our 2011 experience.) […]

  5. Halloween 2016 count | A bunch of data Says:

    […] Here’s a graph of the numbers of trick-or-treat-ers we saw this evening, by time. 10 of the 25 kids arrived in one big group. (Compare this to our 2011 experience.) […]

Comments are closed.