Eliminating the legend in Plot Builder

30 views
Skip to first unread message

Bob Muenchen

unread,
Jan 29, 2012, 9:45:08 AM1/29/12
to ded...@googlegroups.com
Hi All,

I'm creating a histogram that is faceted by two factors like this:

library("ggplot2")
data(mpg)
ggplot(mpg, aes(cty, fill = drv) ) + 
  geom_histogram() + 
  facet_grid(drv ~ cyl) +
  opts(legend.position = "none")

I'm filling with color by the row facet factor just to help the reader focus on the rows. Since the facets are already labeled the legend is redundant. It's easy to eliminate the legend by setting legend.position="none" using code but in Plot Builder I only see how to move it from right to left. Is there a workaround?

Thanks,
Bob

Bob Muenchen

unread,
Mar 9, 2012, 12:40:28 PM3/9/12
to ded...@googlegroups.com
This same issue applies to any plot that you can label directly. One of my favorites is a line plot showing several lines which are labeled in the plot itself. That lets the reader avoid looking back and forth between the lines and the legend. It's a little more work, but worth it if you can suppress the default legend. -Bob

Helios De Rosario

unread,
Mar 12, 2012, 9:47:09 AM3/12/12
to Deducer
The "options" dialog in the "other" tab does contain a field for
"position" of legend. You can choose "none" in that field, and I would
expect that to add the argument legend.position='none' in the code,
but it actually adds position='none'. I suspect that the problem is
there.

Helios

Ian Fellows

unread,
Mar 14, 2012, 6:47:16 PM3/14/12
to ded...@googlegroups.com
Ah yes, thanks for the report. I have fixed this in the development
version. I have also added position_fill, which bob noticed was
missing. A new version should be making its way to CRAN shortly.

Ian

Reply all
Reply to author
Forward
0 new messages