Creating the following plot results in the legend being placed vertically, on the right, rather than on the bottom horizontally as indicated in the call to opts():
dat <- data.frame(x = runif(10), y = runif(10),
grp = rep(letters[1:2],each = 5))
ggplot(data = dat, aes(x = x, y = y, colour = grp)) +
geom_point() +
opts(legend.position = "bottom", legend.direction = "horizontal") +
theme_bw()

How do I get the legend in the correct spot?
The problem is that that
theme_bw()is placed after the call toopts(), and resets some defaults. Just placetheme_bw()beforeopts():Note: Since version 0.9.2
optshas been replaced bytheme: