You can use the theme() with the argument "legend.direction" to change the position of legends.The following example positions the legends horizontally.
plt <- ggplot(df, aes(x=x, y=y,...)) +theme(legend.direction="horizontal")
plt <- ggplot(df, aes(x=x, y=y,...)) +
theme(legend.direction="horizontal")