Skip to content

geom_brick does not accept factor variables for fill, only character #2

@shuze123

Description

@shuze123

Hi,

Thanks a lot for creating ggbrick — geom_brick is a really cool visualization extension! However, I ran into an issue regarding the fill aesthetic.


Problem

When using a factor variable for fill, geom_brick fails with an error like:

Error in scale_fill_discrete():
! Continuous values supplied to discrete scale.
ℹ Example values: 5, 5, 5, 5, and 5

Even though I explicitly convert the column with factor(type), ggbrick still seems to treat it as continuous, or the scale detection does not work properly.


Minimal Reproducible Example

library(ggbrick)
library(ggplot2)

df <- data.frame(
  group = rep(c("A", "B"), each = 10),
  type = factor(rep(c("X", "Y"), each = 5, times = 2)),
  value = sample(1:100, 20)
)

ggplot(df, aes(x = group, y = value, fill = type)) +
  geom_brick(color = NA, size = 0.2)



Thanks again for the package and your time!

Best,

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