So here we are.
The chart is displaying a woman’s age versus the age of the men who look best to her. That is, the age of the men she’s most attracted to. Presumably, humans are attracted to people who are about the same age as themselves.
General Approach
I’m going to use ggplot2 to create the charts. I’ll start with a basic plot, then build it up from there. Once the structure is right, I’ll start taking away graphical elements.Step by Step
I’ve put some data in a .csv (which I’m not going to share here, because that’s a little too close to stealing. I’ll revisit that later if anyone cares.), then read it into a dataframe. As you see, this is just a simple 2 column dataframe with the data.df <- read.csv(data_file)
head(df)
## womans.age age.of.man.who.looks.best
## 1 20 23
## 2 21 23
## 3 22 24
## 4 23 25
## 5 24 25
## 6 25 26
To start with, I’ll need a base plot to build from. The woman’s age is along the y-axis, with the man’s age along the x. The labels are for the points on the chart. One of Tufte’s principles is to have each pixel of information be meaningful. It’s frequently helpful to have text labels on your plot than blobs of color; specifying the labels helps us do that in the next step.plot <- ggplot(data = df,
aes(x = age.of.man.who.looks.best,
y = womans.age,
label = age.of.man.who.looks.best))
Now that I have the base plot, I can build it up.A typical first step I might take with this data is to create a scatterplot to understand what’s going on:
plot + geom_point()
Now, Rudder’s original plot was basically a table. I skipped that step. But what that plot had that mine doesn’t is the following:- The y-axis had all ages, in black.
- The y-axis was increasing going down.
- The labels were red.
- It had a title.
plot <- plot +
geom_text(color = 'red', size = 3) +
scale_y_reverse(breaks = seq(20, 50, 1)) +
theme(axis.text.y = element_text(color = 'black')) +
ggtitle("a woman's age vs the age of the men who look best to her")
print(plot)
We’re getting there. Now, let’s add a line indicating our ‘assumption’, that humans are attracted to people the same age as them.
plot <- plot +
xlim(20, 50) +
geom_abline(linetype = 'dashed', intercept = 0, slope = -1)
print(plot)
Now, there are 2 things left to do: Remove the gray shading in the background and the axis labels, and format the title. With ggplot2, theme() is used to format any non-data element. Since we want to remove almost everything, we set each of the non-data elements we want gone to ‘element_blank()’.
plot <- plot +
theme(axis.ticks = element_blank(),
axis.title = element_blank(),
axis.ticks.x = element_blank(),
axis.text.x = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
plot.title = element_text(hjust = 0,
face = 'italic'))
print(plot)
final_plot <- ggplot(data = df,
aes(x = age.of.man.who.looks.best,
y = womans.age,
label = age.of.man.who.looks.best))
final_plot <- final_plot +
geom_abline(linetype = 'dashed', intercept = 0, slope = -1) +
geom_text(color = 'red', size = 4) +
scale_y_reverse(breaks = seq(20, 50, 1)) +
theme(axis.text.y = element_text(color = 'black')) +
ggtitle("a woman's age vs the age of the men who look best to her") +
xlim(20, 50) +
theme(axis.ticks = element_blank(),
axis.title = element_blank(),
axis.ticks.x = element_blank(),
axis.text.x = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
plot.title = element_text(hjust = 0,
face = 'italic'),
text = element_text(size = 12),
title = element_text(size = 12))
print(final_plot)
png(filename="women_v_men.png",
width=600,
height=600,
res=80)
print(final_plot)
dev.off()
One thing is still missing: Multi-colored title.
I can’t figure out how to make the title multi-colored. Rudder has his title colored, with the “age of the men who look best to her” in red, to match the color of the men’s ages in the plot. This is important, because Rudder uses the title as a legend. If anyone knows, please leave it in the comments, and I’ll update.Design Elements: Tufte’s Influence
I mentioned at the beginning that Rudder designed his charts with Tufte’s recommendations in mind. Here’s how I see the influence in this plot:- Data-Ink. Tufte recommends that the proportion of ink used to display data to ink used to print the graphic should be close to 1. That is, there should be little ink on the plot that doesn’t explicitly display a data point. In fact, Tufte recommends a practice of iteratively removing more graphical ink from the plot over and over, to really discover that point where too much data ink has been removed.
- Multi-Functioning Graphical Elements. An basic approach to displaying this data may be a scatterplot, with or without an accompanying label. However, with the scatterplot approach, you need more non-data-ink to interpret the dots, such as grid lines and axis labels. Here, Rudder has used the labels as the data points, which allows him to remove the grid lines and axis labels, yet doesn’t reduce the legibility or understandability of the chart. Additionally, he uses the title as a legend, as a way to reduce both non-data-ink and make the title a multi-functioning element.






No comments:
Post a Comment