# The Quantified Shelf

At the beginning of this year, my daughter made a resolution to write down every unique book she finished in the year. My wife and I were of course supportive. Every book would count, from Elephant and Piggie through Dog Man, D’Aulaire’s Book of Greek Myths, and The Bootlace Magician.

But New Year’s resolutions are New Year’s resolutions; a week or so in she had lost the zeal. But while she was maintaining it, I decided to create a visualization of the project. My idea was for her to have a picture at the end of the year that sort of looked like a bookshelf of all the books she finished, with the thickness of the book corresponding to the number of pages. To that end, I quietly converted her list into a spreadsheet and updated it even when her paper list lagged behind.

Then I began working on the visualization. I looked at a few approaches: Python, R, Logo. But I ended up with Processing, a Java-based framework for interactive graphics, and the logic was straightforward. For each book in the spreadsheet, draw a rectangle of proportional width in a random color, draw a rotated blob of text with the title and author. Move to the next.

I showed it to my daughter, and she was intrigued. I saw ways to improve.

Did you know that the Amazon web page for a physical book lists the height? I don’t know why you’d need that information in general (“Can’t buy that book; It won’t fit on the shelf!”) but when you’re trying to build a digital illustration of books you’ve read, it’s a crucial component. Now my spreadsheet includes the height, and a quick code change allowed me to draw books of the right proportional width and height. Picture books look tall and thin on the digital shelf. Chapter books range from squat and slim to a bit taller and fatter.

The bookshelf was coming together. But I found the randomized colors hard to keep track of; the shelf looked different each time. I added two new columns to the spreadsheet: spine color and spine text color. I made a simple script in Google Sheets that would fill a cell with the RGB values of the background color of the cell. All I need to do is set the background to the color that seems closest, run my script, and my spreadsheet will have a column that my bookshelf program can parse as colors. No colors available? Revert to random choice.

Now, for instance, Dog Man always shows up as black with white text. Just like the book. The Tale of Despereaux ends up as red with yellow type.

I had the color of the type right, but I was using a consistent size across all the books. This meant that the text on, for instance, Z Is for Moose, overflowed its edges while the type on Dog Man looked adrift in a sea of black. Back to the editor. Within an hour or so, I had code that would size the font to just fit the rectangle.

And finally, I decided that one long shelf had a certain stylistic appeal, but a “bookcase” would be more practical for printing. I added a “Month” column to the spreadsheet, and added a small amount of code so that each shelf would be a month. At some point I’ll draw in a faux bookcase and label each shelf.

Maybe not “finally” after all. I’d like to encode the font somehow, so that The Tale of Despereaux would be written in a florid script like the real book. Also I think some titles would work better if the title and author were on two lines rather than one. And while I have a printout in mind at the end, maybe some code to download and display the cover image from Amazon when you hover over a spine …

While I personally went, possibly maybe, a skosh overboard, just having the information in a spreadsheet allows all sorts of interesting slicing and dicing via pivot tables and the normal built-in charts. While our daughter has finished roughly equal numbers of picture books, graphic novels, and chapter books, about fifty percent of the pages she’s read have been in graphic novels (she’s on a graphic novel tear at the moment, so this isn’t surprising). I have the pie charts to show it. Chuck the data into a histogram, and you’ll see that she has two ranges of page counts, a big spike in the 40-page range (picture books), and a mound in the 150-250 range (chapter books and graphic novels).

So whose project is this, exactly, these days? Let’s say both. Our daughter loves looking at the latest version of the bookcase, remembering the books she’s read, even after just six weeks. She enjoys seeing how the charts reflect her reading and will comment on it and ask questions. She dutifully tells me when she finishes a book at school so it gets on the list. I enjoy the programming exercise, seeing the trends, and making the data visualization I want.