Skip to content

Instantly share code, notes, and snippets.

@jalapic
Created October 23, 2015 18:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jalapic/03b22e4d5e1cfcacc1ae to your computer and use it in GitHub Desktop.
Save jalapic/03b22e4d5e1cfcacc1ae to your computer and use it in GitHub Desktop.
### Earnings Dumbbell Chart
library(ggplot2)
library(tidyr)
library(dplyr)
library(scales)
schoolearnings <- read.csv("schoolearnings.csv", stringsAsFactors=FALSE)
df <- schoolearnings %>% gather(gender,value,2:3)
men <- df %>% filter(gender=="Men") %>% arrange(desc(value)) %>% .$School
df$School <- factor(df$School, levels=rev(men))
schoolearnings$School <- factor(schoolearnings$School, levels=rev(men))
## Nice dotchart
ggplot() +
geom_segment(data=schoolearnings, aes(x=Women, xend=Men, y=School, yend=School), color="gray77",lwd=1)+
geom_point(data=df, aes(value, School, group=gender,color=gender), size=5) +
scale_color_manual(values=c("thistle4", "tomato4"))+
scale_x_continuous(breaks = seq(60,160,20), labels=c("$60k", "$80k","$100k","$120k","$140k","$160k")) +
ggtitle("Gender earnings disparity - 10 years after enrollment") +
xlab("") + ylab("") +
theme(
plot.title = element_text(hjust=0,vjust=1, size=rel(2.3)),
panel.background = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_line(color="gray70",linetype = c("28")),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
plot.background = element_blank(),
text = element_text(color="gray20", size=10),
axis.text = element_text(size=rel(1.0)),
axis.text.x = element_text(color="gray20",size=rel(1.8)),
axis.text.y = element_text(color="gray20", size=rel(1.6)),
axis.title.x = element_text(size=rel(1.5), vjust=0),
axis.title.y = element_text(size=rel(1.5), vjust=1),
axis.ticks.y = element_blank(),
axis.ticks.x = element_blank(),
legend.position = "none"
)
School Women Men gap
MIT 94 152 58
Stanford 96 151 55
Harvard 112 165 53
U.Penn 92 141 49
Princeton 90 137 47
Chicago 78 118 40
Georgetown 94 131 37
Tufts 76 112 36
Yale 79 114 35
Columbia 86 119 33
Duke 93 124 31
Dartmouth 84 114 30
NYU 67 94 27
Notre Dame 73 100 27
Cornell 80 107 27
Michigan 62 84 22
Brown 72 92 20
Berkeley 71 88 17
Emory 68 82 14
UCLA 64 78 14
SoCal 72 81 9
@jalapic
Copy link
Author

jalapic commented Oct 23, 2015

earnings_dotchart

@jalapic
Copy link
Author

jalapic commented Oct 23, 2015

The data may be +/- a thousand $ per data point as I estimated them from a different figure !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment