Legend title and key label for boolean variables

268 views
Skip to first unread message

Stavros Macrakis

unread,
Apr 30, 2009, 11:47:48 AM4/30/09
to ggplot2
In current ggplot2, a Boolean variable's legend looks like a factor's legend where the values are TRUE and FALSE, something like this:

Weekday
   X  TRUE
   Y  FALSE

(where X and Y are the keys).  This is all perfectly logical and consistent, but I think it would be more elegant and helpful if it looked like:

X  Weekday
Y  ~Weekday

(no legend title) or

X  Weekday
Y  other

And if it is going to remain with a legend title, it might be more user friendly to translate the ugly all-caps TRUE -> Yes, FALSE -> No.

          -s

David Kahle

unread,
Apr 30, 2009, 12:17:10 PM4/30/09
to macr...@alum.mit.edu, ggplot2
Hi Stavros -

It seems to me like for each instance you can simply change the labels, like

a <- rep(c(TRUE,FALSE), 50)
qplot(a, data = data.frame(a = a), geom = 'bar', fill = a) +
  scale_fill_discrete('', labels = c('t','f'))

or whatever you might prefer; so the question is more the default.  One of the disadvantages of the other methods you listed is that in many cases it will widen the legend box and make the plot smaller.  So the current default seems pretty reasonable to me.

On the other hand, you have a good point with the TRUE/FALSE labels, but I think True/False is probably a better default.  I hadn't really noticed it before. :)

cheers
david.

Stavros Macrakis

unread,
Apr 30, 2009, 7:02:16 PM4/30/09
to ggplot2
Yes, it is just a suggested change to the default presentation, and I agree that it potentially makes the legend box bigger.
ggplot2 is so beautiful in so many ways that this seems like a reasonable sort of tweak....

            -s

hadley wickham

unread,
May 3, 2009, 7:47:34 PM5/3/09
to macr...@alum.mit.edu, ggplot2
Hmmm, it's a good idea - I definitely agree the display of logical
variables could be better. I can't immediately see anyway to
implement the changes, so I'll add it to my to do list, and hopefully
get to it over the summer.

Regards,

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