Skip to content

Bug: patterns in legend keys #5593

Closed
Closed

Description

@teunbrand

When providing a plain pattern as a fixed 'fill' aesthetic, the fill is not transferred to the legend key fill.

library(scales)
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.4.4.9000'

grad <- grid::linearGradient(pal_viridis()(10))

p <- ggplot(mpg, aes(factor(cyl), colour = "fixed"))

p + geom_bar(fill = grad)

If we instead provide the pattern as a list, it works fine.

p + geom_bar(fill = list(grad))

Created on 2023-12-18 with reprex v2.0.2

The culprit seems to be the following line:

layer_params <- layer$aes_params[n == 1]

Where only params of length 1 are included in the legend. Since a pattern is a list, it does not have length 1.

Activity

  1. teunbrand commented on Dec 18, 2023

    @teunbrand
    CollaboratorAuthor

    Considered fixed by #5595.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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