[R] ggplot map bounds

Adrienne Wootten amwootte at ncsu.edu
Mon Nov 1 15:52:33 CET 2010


To all,

I'm working with code below to produce a map with station data plotted in
points, but right now I'm having trouble with the mapping portion of this
code


states <- data.frame(map("state", plot=FALSE,xlim=
c(-85,-75),ylim=c(33,37))[c("x","y")])
usamap<- ggplot(states)+geom_path(aes(x,y))
usamap

When I plot this the problem is that the bounds of the plot is from 31N to
38N and 90W to 75W.  The problem is that I only need the bounds of the plot
to be from 33N to 37N and 85W to 75W.  The way this is now, if I try to
subset the states object, I get a garbled mess of lines.  The rest of the
code provides what I'm trying to do with the attached data.


usamap + geom_point(data=obsmeans,aes(x=lon,y=lat,colour = month_1),size=5)
+
scale_colour_gradientn(data=obsmeans,colour=rev(rainbow(17)),breaks=seq(5,21,by=1),limits=c(5,21))


Any ideas for how I can fix this map would be appreciated!

Adrienne

-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University


More information about the R-help mailing list