Senate, 'Supreme Court Nominations, present-1789' Supreme Court, 'Members of the Supreme Court of the United States' Pew Research Center calculations"Ĭaption <- paste0(strwrap(caption, 160), sep="", collapse="\n") There's a Shiny Gadget (which is moving to the ggThemeAssist package) to help with this.Ĭaption <- "Note: Vacancies are counted as the number of days between a justice's death, retirement or resignation and the successor justice's swearing in (or commissioning in the case of a recess appointment) as a member of the court.Sources: U.S. It's long, so we need to wrap it (you need to play with the number of characters value to suit your needs). One thing we can take care of right away is how to only label every other tick: xlabs <- seq(1780, 2020, by=10) Now, we want to reproduce the original chart "theme" pretty closely, so I've done quite a bit of styling outside of the subtitle/caption. First the data.ĭat <- read.csv("supreme_court_vacancies.csv", col.names=c("year", "wait")) Some points are (no doubt) off by one or two, but precision was not necessary for this riff. So, just for you, I used WebPlotDigitizer to encode the points (making good use of a commuter train home). However, while Pew provided the chart, they did not provide data behind it. It seemed like a good candidate to test out the new ggplot2 additions. I came across this chart from the Pew Research Center on U.S. You’ll need to devtools::install_github("hadley/ggplot2") to use them until the changes get into CRAN. I have thoughts on plot typography which I’ll save for another post, but I wanted to show how to use these new components. plot.caption is right-justified by default. These are styled via two new theme elements (both adjusted with element_text()):Ī “casualty” of these changes is that the main plot.title is now left-justified by default (as is plot.subtitle). Labs(title="Main Title", caption="Where this crazy thing game from") The second is for below-plot annotations (captions), which are added via: Labs(title="The Main Title", subtitle="A well-crafted subtitle") Ggtitle("The Main Title", subtitle="A well-crafted subtitle") The first is for subtitles that appear below the plot title. As I was doing this, jumped in to add below-plot annotations to ggplot2 (which we’re calling the caption label thanks to a suggestion by What’s Changed? It’s yet-another nod to Hadley as he designed the package so well that slipping in annotations to the label, theme
0 Comments
Leave a Reply. |