hafen / geofacet

R package for geographical faceting with ggplot2
https://hafen.github.io/geofacet/
Other
336 stars 43 forks source link

labeller variable pass through with `labeller()` function not working. #132

Open hathawayj opened 6 years ago

hathawayj commented 6 years ago

This code works

household %>%
  ggplot(aes(x = household_wages/100000)) +
  # geom_rect(data = state_labels, aes(fill = p90),
  #   xmin = -Inf, ymin = -Inf, xmax = Inf, ymax = Inf, alpha = 0.5,
  #   inherit.aes = FALSE) +
  stat_ecdf(geom = "step", pad = TRUE) +
  theme_bw() +
  scale_x_continuous(breaks = seq(0, 30, by = 7)) +
  geom_hline(color = "darkgrey", yintercept = c(.1, .9)) +
  labs(x = "Household income (100,000 INR)", y = "Proportion", title = "Distribution of Household Income") +
  facet_wrap(~stateid, labeller = labeller(stateid = label_wrap_gen(10)))

But when I switch to facet_geo() the labels do not wrap

household %>%
  ggplot(aes(x = household_wages/100000)) +
  # geom_rect(data = state_labels, aes(fill = p90),
  #   xmin = -Inf, ymin = -Inf, xmax = Inf, ymax = Inf, alpha = 0.5,
  #   inherit.aes = FALSE) +
  stat_ecdf(geom = "step", pad = TRUE) +
  theme_bw() +
  scale_x_continuous(breaks = seq(0, 30, by = 7)) +
  geom_hline(color = "darkgrey", yintercept = c(.1, .9)) +
  labs(x = "Household income (100,000 INR)", y = "Proportion", title = "Distribution of Household Income") +
  facet_geo(~stateid, grid = india_grid2, labeller = labeller(stateid = label_wrap_gen(10))) 

I can create a reproducible example if you need.

ptoche commented 6 years ago

please reproducible example with reprex() package