One dumb thought at a time

Tag: visualization (Page 1 of 2)

Reconstructing A Complex Graph Using GGPlot2

I came across an old blog post where the author (Jeff Shaffer) attempted to recreate the Pew Research graph (included below) using Tableau. He succeeded—to my eye at least—and made something that looks really attractive and really close to the original Pew graph. See the original blog post for a comparison between the original and his reconstruction

Reading the post got me wondering if I could recreate the Pew graph myself using R and ggplot2. There is a ton of “non-standard” stuff going on in the original Pew graph (for starters, it’s not really one graph. It’s six) and I was curious how close I could get.

Turns out I was able to get pretty close, I think. Here’s my final version side-by-side with the original. There are a couple of detailed that I couldn’t solve (like the graphs are just a little too compressed). And the process of creating this was…fiddly, to say the least. I ended up with numerous ‘magic’ constants that I had to revise over and over until I got something that looked reasonable1 . And one bit—adding spaces to a label to push its alignment left—I’m downright ashamed of (but I couldn’t find another way to accomplish my goal). Still, I’m pretty happy with the final product.

Comparison of Pew Research graph and ggplot2 recreation.

Note, like the original post’s author, I’m not sure I’d argue this is the best way to display this data. The odd axis treatment on the right hand bar charts seems likely to confuse. But, still, this is an attractive visualizations and I’ve always appreciated Pew’s “house” style.

If you’re interested in the code, I’ve posted it to GitHub.

  1. There are a lot more hardcoded constants throughout my code, but seven parameters gave me enough trouble that I created named constants for them. ↩︎

Experiments with ARtsy

I’ve been playing around with the ARtsy package. I’ve just been using the packages predefined functions with (mostly) function defaults. I finished going through a first pass at all the functions today. Here are my favorites among the many trial pieces I created.

The Rise and Fall of generations

My previous post showing the definitions of different generations was in service of creating the chart below. This chart illustrates the “rise and fall” of generations across their lifecycle. As a new generation is born, it’s share of the population increases. Once a generations births have ended, there is a very long tail as people in that generation slowly die and new generations are born.

The data from the chart below comes from the U.S. Census bureau. I was able to use yearly population estimates from 1980 onward, but prior to 1980 the data comes from decennial Census PUMs data (hence why, for example, Gen X looks it starts in 1970–instead of 1965–and why the baby boomers have such an odd slope between 1960 and 1970). The Census Bureau does not publish birth year, so I estimated birth year (and thus generation) from age and year of estimate. There will thus ‘slop’ in my estimates but they should be close for my purpose here.

Chart showing the generational distribution of the U.S. population from 1940 - 2021

Defining the generations

Generations is a very… imprecise… sociological concept. People just sorta look at a rough cohort of ages and say “yeah, you all are a generation.” Start and end points (as well as labels) just sorta coalesce out of the ether.

Nevertheless, they have their use and certainly are cemented in the popular imagination. I’ve been doing some reading on generations and really appreciated this diagram and article by Pew Research. But I wish it went a little earlier and a little later. So I made my owner version, *heavily* influenced by the Pew version.

A diagram showing generation birth year starting with the Lost Generation (born 1883 - 1900) and ending with Generation Alpha (Born 2013-2030).

Fugazi Album Color Palette

Over the next few weeks[efn_note]Let’s be honest, over the next few months/years is more likely.[/efn_note] I’ll be posting an deep-dive data analysis of Fugazi’s live performance history. Why? Why not. All the data is there and I was bored.

I probably saw Fugazi perform a dozen times. Attending college outside of DC during the early ’90s made it easy. They played a lot, and famously never charged more than $5 for a show (and most of the time I saw them the show was free). I saw them in small venues and big indoor and in the shadow of the Washington monument. And they were never boring.

Since 2011, Fugazi has made recordings of their shows available for download at https://www.dischord.com/fugazi_live_series. To date, playlists and recordings have been posted for 895 (85.4%) of all their shows. Across their entire career, Fugazi played 23,201 songs. In future blog posts, I’m going to analyze those performances. Again, for absolutely no good reason.

Color palette

One idea that I had for the analysis was to use the dominant album colors for the visualizations. I’m not sure that’s actually going to work because several of the albums used very similar palletes (they certainly seemed to have liked their olivey greens). But it resulted in a kinda cool image, nonetheless.

I’m not sure why anyone would need or want it, but here’s my “Fugazi album color pallete” for reference.

cols <- c("13 Songs" = "#B60400", 
          "Repeater + 3 Songs" = "#313855",
          "Steady Diet of Nothing" = "#703F13", 
          "In on the Kill Taker" = "#DFC370",
          "Red Medicine" = "#797C57",
          "End Hits" = "#776342",
          "The Argument" = "#45787F",
          "Furniture" = "#41242B",
          "First Demo" = "#3C3D2B")

(Next Fugazi Post)

« Older posts

© 2024 Overthinking it

Theme by Anders NorenUp ↑