library(ggplot2)
library(scales)
data.frame(
yrs=c("1789-90", "1849-50", "1909-10", "1965-66", "2016-16"),
pct=c(0.526, 0.795, 0.713, 0.575, 0.365),
xtralabs=c("", "Highest:n", "", "", "Lowest:n")
) -> hill_lawyers
gg ggplot(hill_lawyers, aes(yrs, pct))
gg gg + geom_bar(stat="identity", width=0.65)
gg gg + geom_label(aes(label=sprintf("%s%s", xtralabs, percent(pct))),
vjust=-0.4, family=c(rep("FranklinGothic-Book", 4),"FranklinGothic-Heavy"),
lineheight=0.9, size=4, label.size=0)
gg gg + scale_x_discrete()
gg gg + scale_y_continuous(expand=c(0,0), limits=c(0.0, 1.0), labels=percent)
gg gg + labs(x=NULL, y=NULL, title="Fewer and fewer lawyers on the Hill")
gg gg + theme_minimal(base_family="FranklinGothic-Book")
gg gg + theme(axis.line=element_line(color="#2b2b2b", size=0.5))
gg gg + theme(axis.line.y=element_blank())
gg gg + theme(axis.text.x=element_text(family=c(rep("FranklinGothic-Book", 4),
"FranklinGothic-Heavy")))
gg gg + theme(panel.grid.major.x=element_blank())
gg gg + theme(panel.grid.major.y=element_line(color="#b2b2b2", size=0.1))
gg gg + theme(panel.grid.minor.y=element_blank())
gg gg + theme(plot.title=element_text(hjust=0,
Source:: r-bloggers.com
|