-2

enter image description here

enter image description here

The above shows 2 legends, one where each item is placed in a new column and one where each item is placed in a new row.

How can I control for that?

  • Do you mean you want two legends in two different directions? Perhaps a simple reproducible example would be helpful here. – Allan Cameron Feb 07 '22 at 13:26
  • no, I want them both in the same direction – Bear Bile Farming is Torture Feb 07 '22 at 13:26
  • Can you show us the code that produces the two different legends in a single plot? They normally _do_ go in the same direction, so some data and code that reproduces the problem would be helpful here – Allan Cameron Feb 07 '22 at 13:28
  • 1
    Does this answer your question? [ggplot2 legend to bottom and horizontal](https://stackoverflow.com/questions/10032513/ggplot2-legend-to-bottom-and-horizontal) – Maël Feb 07 '22 at 13:31

1 Answers1

1

This is controlled by the nrow and ncol arguments to guide_legend().

You can call guide_legend() either within guides():

plot + 
  guides(color = guide_legend(nrow = 1))

…or within scale_*():

plot +
  scale_color_discrete(guide = guide_legend(nrow = 1))
zephryl
  • 14,633
  • 3
  • 11
  • 30