Blog Archives

Plotting letters as shapes in ggplot2

November 5, 2012
By
Plotting letters as shapes in ggplot2

This post is a little more esoteric than most, but I found myself needing to solve this problem, so I’m just passing the solution on to you. The plot above shows the distribution of DW-NOMINATE scores for the 18th Congress, with party indicated ...

Read more »

GGtutorial: Day 5 – Gradient Colors and Brewer Palettes

November 2, 2012
By
GGtutorial: Day 5 – Gradient Colors and Brewer Palettes

So, continuing with the short tutorials on how to do relatively simple (but sometimes very frustrating things) in ggplot, today’s post looks at how to use gradient colors and Brewer colors to color either continuous or discrete dependent variab...

Read more »

GGtutorial: Day 4 – More Colors

November 1, 2012
By
GGtutorial: Day 4 – More Colors

So far we’ve covered Melting and Casting data using the reshape() package and today we’re going to look at different ways of coloring and selecting palettes for plots. For these plots, we’re going to use the built in diamonds data...

Read more »

GGtutorial: Day 3 – Introduction to Colors

October 31, 2012
By
GGtutorial: Day 3 – Introduction to Colors

So, where does ggplot get its colors? If you’ve ever asked ggplot to color on the basis of a factor, you might have beeen surprised by the default color choices.  The fact is, ggplot colors factors on the basis of finding evenly spaced colors a...

Read more »

Plotting correlation ellipses

October 26, 2012
By
Plotting correlation ellipses

This is an oldie but a goodie. There are a lot of ways to plot multiple bivariate relationships, but this is one of my favorites, courtesy of the R Graph Gallery. https://gist.github.com/819111

Read more »

Congressional ideology by state

October 25, 2012
By
Congressional ideology by state

In a recent post, I illustrated how to add a background geom to your ggplot. While that code worked, and the plot looked fine, it was pointed out to me that I was missing an important aspect of plot layering with ggplot2. Namely, it is not, as I previ...

Read more »

Plotting the debate "Winner"

October 24, 2012
By
Plotting the debate "Winner"

As a Political Scientist, it could not be more gauche to talk about the Presidential debate in terms of a winner and a loser, but the occasion provides the opportunity to show how to do (at least) three really useful things: Directly load price and v...

Read more »

Benchmarking matrix creation

October 23, 2012
By
Benchmarking matrix creation

Sometimes it is useful to take a vector, or one column/row of a matrix, and build a new matrix of identical copies of that vector. There are lots of different ways to do this, but I just discovered a new, and very straightforward way to do this with m...

Read more »

Distribution of colors by flag

October 22, 2012
By
Distribution of colors by flag

A story: We showed you how to use R to assess flag similarity and make a scatter plot of raster images. Dr. Wickham referred us to the set of 2400 flag icons made available by GoSquared, and then (probably jokingly) challenged us to replicate the cool...

Read more »

Adding a background to your ggplot

October 19, 2012
By
Adding a background to your ggplot

I really enjoy using the DW-NOMINATE data for examples, as I do here. Sometimes it’s useful to indicate regions in the background of a plot — perhaps two-dimensional regions of interest, perhaps one-dimensional periods in time. It’s...

Read more »