--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
Are you trying to construct a choropleth map? If so, then you should
probably install the development version of ggplot2-0.9.0 and consider
using geom_map() in the new version (it doesn't exist in 0.8.9). If
that's what you're after, let us know and we can show you how to
install it and get moving with it. The geom_map() help page and my
0.9.0 transition guide (which isn't quite ready for release to this
group yet but will probably be by next week) have an example using a
US map with a choropleth plot.
HTH,
Dennis
The problem is that when you call facet_wrap(), there's no referent
data frame for liberal_arts. One way to resolve the problem is shown
below. I played around with a few other things, too, including aspect
ratios. Take the opts() code out and see what happens :)
library('ggplot2')
library('maps')
library('maptools') # you forgot these...
mydata <- read.csv(file=url("http://dl.dropbox.com/u/6517578/tmp.csv"),
header=TRUE, row.names=1, sep=",")
all_states <- map_data("state")
# Don't know why you included the Dakotas since there are no points
# in either state - you could remove them WLOG and enlarge the faceted
# maps a bit
states <- subset(all_states, region %in% c( "illinois", "indiana", "iowa",
"kentucky", "michigan", "minnesota","missouri", "north dakota",
"ohio", "south dakota", "wisconsin" ))
# Use mydata as the data argument so that liberal_arts
# has a referent data frame when invoked
ggplot(mydata) +
geom_polygon( data=states, aes(x=long, y=lat, group = group),
fill = 'grey 40', colour="skyblue" ) +
geom_point(aes(x=long, y=lat, label=label),
hjust=0.5, vjust=-0.5, colour="gold2", size=3 ) +
opts(aspect.ratio = 1) +
facet_wrap(~ liberal_arts, ncol = 1)
In 0.9.0, the extended spacing between the vertical axes and the axis
label is fixed. (See the attachments.)
The original blog post was fine because the poster didn't try to facet
by a variable - in that case, the ggplot() call with no arguments was
fine since each subsequent layer defined the data frame to be used in
that layer. When you decided to experiment with faceting, you
neglected to realize that liberal_arts had no reference for ggplot()
to use, hence the error. Once you put mydata in the ggplot() call as
above, facet_wrap() can point back to it and retrieve the liberal_arts
variable.
Dennis