custom grid + facet_geo not happening as expected, and I don't know why

First, I built a custom grid:

# define pacific grid
my_grid <- data.frame(
  row = c(5, 6, 6, 3, 2, 3, 2, 1, 6, 3, 6, 6, 4, 7, 3, 4, 4, 6, 4, 5, 5, 5),
  col = c(6, 7, 4, 2, 2, 4, 3, 2, 3, 3, 6, 8, 2, 9, 1, 3, 5, 5, 4, 3, 4, 5),
  code = c("AS", "CK", "FJ", "FM", "GU", "KI", "MH", "MP", "NC", "NR", "NU", "PF", "PG", "PN", "PW", "SB", "TK", "TO", "TV", "VU", "WF", "WS"),   
  name = c("American Samoa", "Cook Islands", "Fiji", "Micronesia (Federated States of)", "Guam", "Kiribati", "Marshall Islands", "Northern Mariana Islands", "New Caledonia", "Nauru", "Niue", "French Polynesia", "Papua New Guinea", "Pitcaim Island", "Palau", "Solomon Islands", "Tokelau", "Tonga", "Tuvalu", "Vanuatu", "Wallis and Futuna", "Samoa"),
  stringsAsFactors = FALSE
)
geofacet::grid_preview(pacific_grid)

It worked:

and then I used facet_wrap to make the plot:

# plot
ggplot(data = plot_data) +
  geom_arc_bar(
    mapping = aes(x0 = 0, y0 = 0, r0 = 2, r = 4, start = 0, end = end),
    fill = fill_col,
    colour = NA
  ) +
  geom_arc_bar(
    mapping = aes(x0 = 0, y0 = 0, r0 = 2, r = 4, start = 0, end = end1),
    fill = end1_col,
    colour = NA
  ) +
  geom_arc_bar(
    mapping = aes(x0 = 0, y0 = 0, r0 = 2, r = 4, start = 0, end = end2),
    fill = end2_col,
    colour = NA
  ) +
  geom_text(
    mapping = aes(x = 0, y = 0, colour = text_col, label = paste0(renewdata, "%"))
  ) +
  facet_wrap(~name)+

it worked too:

but i used facet_geo instead, the code like this:

ggplot(data = plot_data) +
  geom_arc_bar(
    mapping = aes(x0 = 0, y0 = 0, r0 = 2, r = 4, start = 0, end = end),
    fill = fill_col,
    colour = NA
  ) +
  geom_arc_bar(
    mapping = aes(x0 = 0, y0 = 0, r0 = 2, r = 4, start = 0, end = end1),
    fill = end1_col,
    colour = NA
  ) +
  geom_arc_bar(
    mapping = aes(x0 = 0, y0 = 0, r0 = 2, r = 4, start = 0, end = end2),
    fill = end2_col,
    colour = NA
  ) +
  geom_text(
    mapping = aes(x = 0, y = 0, colour = text_col, label = paste0(renewdata, "%"))
  ) +
  geofacet::facet_geo(~ name, grid = pacific_grid) +

it didn't happen as expected, some facet missing without warnings:

I have checked the difference of the plot data and my grid using setdiff, it said no

setdiff(pacific_grid$name, plot_data$name)
character(0)

Anybody know that? why? THX

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.