+1 vote
in Programming Languages by (60.0k points)
In the plot created using ggplot, the legends are vertical. I want to position them horizontally. How to do it?

1 Answer

+4 votes
by (354k points)
selected by
 
Best answer

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")

Related questions

+1 vote
1 answer
+1 vote
1 answer
+5 votes
1 answer
+3 votes
1 answer
+3 votes
1 answer

...