Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add option to customizer (e.g., capitalize) country names on legend #35

Open
rempsyc opened this issue May 31, 2024 · 0 comments

Comments

@rempsyc
Copy link

rempsyc commented May 31, 2024

It seems it is not currently possible to customize the country names on the legend, either by capitalization or full names.

library(ggflags)

# Capitalized country names don't work
d <- data.frame(
  x = rnorm(10), y = rnorm(10),
  country = sample(c("AR", "FR"), 10, TRUE),
  stringsAsFactors = FALSE
)
ggplot2::ggplot(d, ggplot2::aes(x = x, y = y, country = country)) +
  geom_flag() +
  scale_country()
#> Error in (function (classes, fdef, mtable) : unable to find an inherited method for function 'grobify' for signature '"NULL"'

# Lower case works
p <- ggplot2::ggplot(d, ggplot2::aes(x = x, y = y, country = tolower(country))) +
  geom_flag() +
  scale_country()
p

# Specifying legend labels is ignored
p + ggplot2::scale_fill_discrete(labels = c("AR", "FR"))

p + ggplot2::scale_color_manual(labels = c("AR", "FR"))

                        
p + ggplot2::scale_color_hue(labels = c("AR", "FR"))

Created on 2024-05-31 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant