I was unable to find a solution for putting ggplot2 legend in 2 rows.
Example
library(ggplot2)
theme_set(theme_bw())
data("midwest", package = "ggplot2")
ggplot(midwest, aes(x=area, y=poptotal)) +
geom_point(aes(col=state, size=popdensity)) +
geom_smooth(method="loess", se=F) +
xlim(c(0, 0.1)) +
ylim(c(0, 500000)) +
labs(y="Population",
x="Area",
title="") +
theme(legend.position = "top")
In the above image, I would like to have popdensity annotation on top (first row) and state annotation in the second row.

