Skip to content

scale_color_stepsn() will not accept expression vector for scale labels #6005

Closed
@palderman

Description

@palderman

An error is generated when attempting to specify color scale labels as a plotmath expression vector. The error is also generated when using scale_fill_stepsn(). I expected the color scale labels to be rendered using plotmath.

Here is code to reproduce the bug:

library(ggplot2)
data.frame(x = 1:5, y = 1:5) |>
  ggplot(aes(x = x, y = y, color = y))+
  geom_text(label = parse(text = paste0("x^", 1:5)))+
  scale_color_stepsn(breaks = 1:5,
                                  colors = c("red", "orange", "yellow","green", "blue"),
                                  labels = parse(text = paste0("x^", 1:5)))
#> Error in `vec_size()`:
#> ! `x` must be a vector, not an expression vector.

Created on 2024-07-17 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorguides 📏

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions