I am trying to format a long legend on ggplot so that there is a maximum number. lines. I read all the documentation I could find, especially this: http://docs.ggplot2.org/0.9.3.1/guide_legend.html , but for some reason the legend will not be formatted.
I cited the reproducible sample below using the earthquake dataset and converted the column stations to a symbol so that they are displayed individually (otherwise they appear to be displayed as groups).
plotquakes <- function(magreq) { library(ggplot2) magdata <- subset(quakes, mag > magreq) magdata$stations <- as.character(magdata$stations) g <- ggplot(magdata, aes (x = lat, y = long)) g + geom_point(aes(alpha = stations), fill = "black", pch=21, size = 6) + labs(x = "Latitude", y = "Longitude") + geom_vline(xintercept = 0, col = "red") + geom_hline(yintercept = 0, col = "red") + guides(col = guide_legend(nrow = 16)) } plotquakes(5)
And I get the following:

whereas I would like to have a maximum of 16 data fields in a column in a legend.
source share