In the first version, the alpha value is clearly being applied to the
_entire_ legend, even the size scale. Am I placing the alpha
parameter in the wrong place?
Is there no way to force the alpha parameter to be applied only to the
data points themselves, not the legend?
Would you be defeating the intent of the legend as a reflection of the plot? The behavior seems expected rather than weird to me.
I _think_ that the only way to do this is with grids and viewports. You could capture a legend of a plot without alpha set, create an appropriately dimensioned grid, print a plot (with alpha set and without a legend) to a viewport, print the captured legend to another viewport on the grid. Maybe a better way will show up in the responses.
> In the first version, the alpha value is clearly being applied to the > _entire_ legend, even the size scale. Am I placing the alpha > parameter in the wrong place?
> Is there no way to force the alpha parameter to be applied only to the > data points themselves, not the legend?
On Jun 5, 11:28 am, Mark Connolly <mark_conno...@acm.org> wrote:
> Would you be defeating the intent of the legend as a reflection of the
> plot? The behavior seems expected rather than weird to me.
Generally, I'd agree. I think I could make a strong case, though,
that alpha blending is an exception and should _never_ be applied to
the legend. The legend should display the color I've chosen, not 1/20
(or whatever) of the color I've chosen. I can't imagine a situation
where I'd actually want very dim, faintly colored items in my legend.
Additionally, you'll notice in the example code I gave, the alpha
blending is applied even to the size scale, which has nothing to do
with the colors scale being used. Why dim every single symbol in the
legend? That just makes no sense to me, but I'm certainly open to
correction...
I suppose one option would be to actually add an entirely new legend
scale every time you use alpha blending that shows the depth of color
changes as items are overplotted, and this would be separate from any
color scale, which would be displayed with the "true" colors.
But in any case, at least I think your answer confirms that there is
no (easy) way to do what I want, at least at the moment...
> I _think_ that the only way to do this is with grids and viewports. You
> could capture a legend of a plot without alpha set, create an
> appropriately dimensioned grid, print a plot (with alpha set and without
> a legend) to a viewport, print the captured legend to another viewport
> on the grid. Maybe a better way will show up in the responses.
> Mark
> On 06/04/2010 05:58 PM,Joranwrote:
> > I've posted about a related issue before, which I was able to resolve
> > kind of, but it's popped up again with a slightly different graph.
> > I just want to know if I'm specifying the graph wrong, or what,
> > because this seems like really weird behavior:
> > In the first version, the alpha value is clearly being applied to the
> > _entire_ legend, even the size scale. Am I placing the alpha
> > parameter in the wrong place?
> > Is there no way to force the alpha parameter to be applied only to the
> > data points themselves, not the legend?
> Generally, I'd agree. I think I could make a strong case, though, > that alpha blending is an exception and should _never_ be applied to > the legend. The legend should display the color I've chosen, not 1/20 > (or whatever) of the color I've chosen. I can't imagine a situation > where I'd actually want very dim, faintly colored items in my legend. > Additionally, you'll notice in the example code I gave, the alpha > blending is applied even to the size scale, which has nothing to do > with the colors scale being used. Why dim every single symbol in the > legend? That just makes no sense to me, but I'm certainly open to > correction...
The underlying principle of the legends is to make them appear as similar as possible as the glyphs that actually occur on the plot. I agree with you that this isn't always what you want for alpha blending, but I'm not willing to make a special case for a single aesthetic. What legends really need is some way to override the defaults so that you can supply the other aesthetics yourself. I've added a ticket to that affect: http://github.com/hadley/ggplot2/issues/issue/109
Hadley
-- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/