0

I created a plot in which I can display the number of flights. I am not able to make a conditional statements or something like that to choose only four colors for n =100, 150, 200, 250 within geom_edge_arc(). I just got several colors for each amount of a number of flights. Can someone give me a hint?


graph_flight %>% 
  activate(edges) %>% 
  filter(n > 90, date == c("2022-03-17", "2022-03-30")) %>% 
  create_layout("manual", x=lon, y=lat) %>% 
  ggraph() +
  geom_sf(data = rnaturalearth::ne_countries(returnclass="sf")) +
  geom_node_point() +
  geom_edge_arc(aes(edge_width = n, colour = factor(n)), alpha=0.25) +
  scale_edge_width_continuous() +
  lims(x=range(data_node$lon), y=range(data_node$lat)) +
  theme_bw() + labs(x = NULL, y = NULL)

enter image description here

Gaaaa
  • 115
  • 9
  • Looks like you need to divide `n` into the desired classes before converting it to factor (this isn't done automatically, although the legend suggests so). See `?cut` for one method to obtain classes. –  Oct 16 '22 at 19:12

0 Answers0