Enoch
Enoch

Reputation: 11

How to "re-arrange" the legend in ggplot2?

I have a plot with several lines representing different columns of data, the legend is being arrange as a vertical column, but I want to place it at the bottom of the chart and arrange the keys horizontally, can it be done? Thanks!

Upvotes: 1

Views: 540

Answers (2)

M. Tibbits
M. Tibbits

Reputation: 8630

It does now. Just use:

opts(legend.position="bottom", legend.direction="horizontal")

Since version 0.9.2, opts has been replaced by theme:

theme(legend.position = "bottom", legend.direction = "horizontal")

Upvotes: 2

Andreas
Andreas

Reputation: 6728

Unfortunately not in the current implementation of ggplot2. Hadley has it on his to-do I think :-)

You can always position the legend manually

opts(legend.position=c(0.5,0.5))

but the keys stays vertical :-/

Upvotes: 0

Related Questions