Re: [R] overlaid transparent histograms

From: hadley wickham <>
Date: Fri, 13 Jun 2008 23:45:44 -0500

> Three questions:
> 1a) Why does the following code not produce transparent bars?

Because you're setting the fill colour (not mapping it to a variable in your dataset), the fill needs to be outside of aes()

g +
 geom_histogram(aes(x=log(BNCw)), fill = alpha("red", .5)) +  geom_histogram(aes(x=log(BNCc)), fill = alpha("blue", .5))

> 1b) How can I manually specify the elements of the legend for this
> version of the plot?

Use the "manual" scale:

g +

geom_histogram(aes(x=log(BNCw), fill = "w")) +
geom_histogram(aes(x=log(BNCc), fill = "c")) +
scale_fill_manual("BNC type", values = alpha(c("red","blue"), 0.5))



______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 14 Jun 2008 - 04:49:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 14 Jun 2008 - 06:30:41 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive