Skip to content

Combined facet labels aren't parsed when .multi_line = FALSE #4084

Closed
@karawoo

Description

@karawoo

(previously: #4032 (comment))

Facet labels that are combined with .multi_line = FALSE don't show up as parsed when using label_parsed:

library("ggplot2")

dat <- data.frame(x = 1, y = 1, a = "a", b = 1)

ggplot(dat, aes(x, y)) +
  geom_point() +
  facet_grid(
    ~ a + b,
    labeller = labeller(
      a = c("a" = "a^2"),
      .default = label_parsed,
      .multi_line = FALSE
    )
  )

Created on 2020-06-22 by the reprex package (v0.3.0)

Compare to .multi_line = TRUE, which looks as it should:

ggplot(dat, aes(x, y)) +
  geom_point() +
  facet_grid(
    ~ a + b,
    labeller = labeller(
      a = c("a" = "a^2"),
      .default = label_parsed,
      .multi_line = TRUE
    )
  )

One issue is the .multi_line argument doesn't get passed along here:

labellers <- lapply(dots, as_labeller, default = .default)

However changing that line alone makes things worse:

ggplot(dat, aes(x, y)) +
  geom_point() +
  facet_grid(
    ~ a + b,
    labeller = labeller(
      a = c("a" = "a^2"),
      .default = label_parsed,
      .multi_line = FALSE
    )
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorfacets 💎

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions