Skip to content

Bug in guide training #5425

Closed
Closed
@teunbrand

Description

@teunbrand

In guide training this assumption is made:

ggplot2/R/guides-.R

Lines 416 to 417 in 25f54d9

# A strong assumption here is that `scales` is parallel to the guides
train = function(self, scales, direction, labels) {

I found out that you can violate this assumption as follows, where the first scale has 2 aesthetics and the second scale has 1 aesthetics.

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
packageVersion("ggplot2") # current main branch
#> [1] '3.4.3.9000'

df <- data.frame(x = (1:3)/3, z = c("red", "blue", "green"))

ggplot(df) +
  aes(x, z, colour = z, fill = z, size = x) +
  geom_point() +
  scale_discrete_identity(aesthetics = c("colour", "fill")) +
  scale_size_identity()
#> Warning in mapply(FUN = f, ..., SIMPLIFY = FALSE): longer argument not a
#> multiple of length of shorter

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

This is probably worth fixing and guaranteeing the assumption more.

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