Skip to content

Instantly share code, notes, and snippets.

@wch
Created September 26, 2012 21:58
Show Gist options
  • Select an option

  • Save wch/3790888 to your computer and use it in GitHub Desktop.

Select an option

Save wch/3790888 to your computer and use it in GitHub Desktop.
Map alignment test
library(gcookbook)
library(ggplot2)
# Take a slice where z is equal to the minimum value of z
islice <- subset(isabel, z == min(z))
# Just the hurricane data
ggplot(islice, aes(x=x, y=y, fill=speed)) + geom_raster(alpha=.5) +
scale_fill_continuous(na.value=NA)
# Get USA map data
usa <- map_data("usa")
# Map outline with hurricane data
ggplot(islice, aes(x=x, y=y)) +
geom_raster(aes(fill=speed), alpha=.5) +
scale_fill_continuous(na.value=NA) +
geom_path(aes(x=long, y=lat, group=group), data=usa) +
coord_cartesian(xlim = range(islice$x), ylim = range(islice$y))
@wch

wch commented Sep 26, 2012

Copy link
Copy Markdown
Author

For information about the data structures, you can do the following:

str(usa)
head(usa)
tail(usa)

str(islice)
head(islice)
tail(islice)

@wch

wch commented Sep 26, 2012

Copy link
Copy Markdown
Author

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