Skip to content

Slab fill alpha combines poorly with outlines #260

@Ax3man

Description

@Ax3man

Hi Matthew,

Thanks for making my favorite ggplot extension package!

slab_alpha applies to both the fill of the slab, as well as the outline. While the alpha can work nicely for slabs with either a fill or an outline, it looks quite poor whenever both are present:

Consider e.g.:

dist_df <- data.frame(mean = 0, sd = 1)

ggplot(dist_df, aes(xdist = dist_normal(mean, sd))) +
  stat_slab(fill = 'firebrick', color = 'black', slab_alpha = 0.6, slab_linewidth = 3)

Image

Half of the outline overlaps with the fill, while the other half does not, which makes the outline look like two outlines.

The desired result can be obtained by manually assigning a color with an alpha value:

ggplot(dist_df, aes(xdist = dist_normal(mean, sd))) +
  stat_slab(fill = scales::alpha('firebrick', 0.6), color = 'black', slab_linewidth = 3)

Image

But perhaps it would be nicer if the alpha of the outline and the fill can be controlled separately, or, if ggdist follows the ggplot convention of applying the alpha only to fills (as in e.g. geom_density()).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions