Skip to content

Introduce new alpha parameter for lines of geom_density(), geom_bar(), and so on #3112

@MaximOtt

Description

@MaximOtt

(It's my first time, and I am really sorry if I waste someones time to close and delete this, but I am kinda confident, that it is the right place.)

I open this issue (again), because as I read it, the last time no real solution was agreed upon, and the confusing behavior is not (easily) resolved. The issue in question can be found here:

#1371

The discussion is very informative, so I will only quote the basic problem:

"When I draw a chart with alpha, I expect that the whole layer, the line and fill, will become transparent. But the line stays clear red."

I would argue, that this is extermely counterintuitive, and apparently some people agree (See link).

Because (of course) some peoples code would be broken by a proposed change, the suggested change has been reverted, and the workaround is to change the color manually with colour=alpha("red", 0.1).

The problem with this solution, is that I can not longer use automatic color picking to highlight a group with color=MyGroupVar, alpha=ifelse(MyGroupVar=="GroupA",0.2,1). I personally think it is very inconvenient, but as I understand the debate, a possible compromise would be to introduce a new parameter alpha_line or something.

Or am I missing a very simple solution for this? (In any case something more "official" than just a workaround of any kind would be nice ^^)

Below is a simple example:

mtcars$cyl = as.factor(mtcars$cyl)
ggplot(data=mtcars, aes(x=disp,fill=cyl, color=cyl, alpha=ifelse(cyl!=6,0.2,1))) +
  geom_bar(width=5,position=position_dodge(preserve = "single"))+
  guides(alpha=FALSE)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions