Legend positioning

14 views
Skip to first unread message

learnr

unread,
Jun 1, 2009, 11:27:34 AM6/1/09
to ggplot2
Based on the ggplot2 draft book p.112 "The position and justification
of legends are controlled by the theme setting legend.position, and
the value can be right, left, top, bottom, none (no legend), or a
numeric position."

However, I am only able to position the legend on the right, the other
values (left, bottom, top) seem to produce no meaningful results at
all.

Am I doing something wrong, or is this a bug?

x <- ggplot(mtcars, aes(wt, cyl, colour = gear)) + geom_point()
x + opts (legend.position = "right") # theme default, works
x + opts (legend.position = "top") # not working
x + opts (legend.position = "bottom") # not working
x + opts (legend.position = "left") # not working
x + opts (legend.position = c(0.7, 0.7)) # working

--
http://learnr.wordpress.com/

learnr

unread,
Jun 1, 2009, 11:32:59 AM6/1/09
to ggplot2
Hmm, I forgot to include the error message I get when using (left,
bottom, top):

Error in grid.Call.graphics("L_setviewport", pvp, TRUE) :
Non-finite location and/or size for viewport

hadley wickham

unread,
Jun 1, 2009, 11:52:49 AM6/1/09
to learnr, ggplot2
Yes, that's right. They are all broken, but on my to do list to fix.
I'm hoping to have a week later this summer to work exclusively on
layout issues.

Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages