Posts Tagged ‘ RColorBrewer ’

Make your own electoral map

November 7, 2012
By
Make your own electoral map

You’ve already seen everyone else’s electoral map (see this amazing array of maps from 2008), how would you like to make your own? Today’s Gist allows you to do just that — input (manually!) state-by-state results, and output a...

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 »

Using cairographics with ggsave()

October 12, 2012
By
Using cairographics with ggsave()

Whenever possible, I try to save R graphic output in a vector format, typically pdf(). I also like to use the handy ggsave() function to do so, as it streamlines the process, and makes it easy to be consistent across formats. However, at times it is n...

Read more »

From holey polygons to convex hulls

October 11, 2012
By
From holey polygons to convex hulls

I only rarely have the occasion to need the convex hull of a set of points, but I love chull(), so I’d like to share an example of how to use it. This Gist also offers a pretty straightforward application of the Split-Apply-Combine strategy (see...

Read more »

Simple marimekko/mosaic plots

October 10, 2012
By
Simple marimekko/mosaic plots

I don’t really care for the name “marimekko” or “mosaic,” but I do like this type of plot as a means of illustrating proportions in nested categorical data, or as an alternative to the parallel time series plots discussed...

Read more »

Transforming a color scale

October 3, 2012
By
Transforming a color scale

In developing plots, I often use color (or “colour” in ggplot2 parlance) to reflect values of a third, non-X/Y, variable. Depending on the distribution of this Z variable, however, the effective color range can be narrow, making it difficul...

Read more »

Simplest possible heatmap with ggplot2

September 27, 2012
By
Simplest possible heatmap with ggplot2

Featuring the lovely “spectral” palette from Colorbrewer. This really just serves as a reminder of how to do four things I frequently want to do: Make a heatmap of some kind of matrix, often a square correlation matrix Reorder a factor vari...

Read more »

An unabashedly narcissistic data analysis of my own tweets. The…

April 2, 2012
By
An unabashedly narcissistic data analysis of my own tweets.
The…

pie( table( whence.i.tweet )) qplot( whence ) + coord_polar() pie( log( table( whence )))+RColorBrewer ggplot (see below) plot( density( tweets.len )) qplot(... stat="density") + geom_density qplot(...stat="bin") + geom_text(...) tweeple tweep...

Read more »

Example 8.13: Bike ride plot, part 2

November 8, 2010
By
Example 8.13: Bike ride plot, part 2

Before explaining how to make and interpret the plot above, Nick and I want to make a plea for questions--it's hard to come up with useful questions to explore each week!As shown in Example 8.12, data from the Cyclemeter app can be used to make interes...

Read more »

Writing a Spatial Function: The Location Quotient

September 7, 2010
By
Writing a Spatial Function: The Location Quotient

Background: In some cases it is necessary to conduct the same analysis multiple times on either the same or different data. In such circumstances it is worth writing a function to simplify the code. In this example the location quotient provides a simple calculation easily written in to a function. The location quotient (LQ) is

Read more »