0

I want to change this plot so that these grey (NA) blocks dissapear. This is my code right now:

df_nr <-  df_skey %>% 
  filter(!is.na(node)) %>% 
  group_by(x, node)%>% 
  summarise(count = n())
df2 <- 
  df_skey %>% 
  left_join(df_nr)

skeyp3 <- ggplot(df2, aes(x = x
                            , next_x = next_x
                            , node = node
                            , next_node = next_node
                            , fill = factor(node)
                            , label = node))+
  geom_sankey(flow.alpha = 1
              ,node.color = "black"
              ,show.legend = TRUE) +
  theme_sankey(base_size = 16) + 
  geom_sankey_text(aes(label = count), size = 3.5, vjust = -1.5, check_overlap = TRUE) +
  theme_minimal()

enter image description here

I tried to filter out where next node is NA, but thats not what I want.

marie
  • 1
  • what about adding `filter(!is.na(node))` for your df2 ? `df_skey %>% left_join(df_nr) %>% filter(!is.na(node))` – dc37 Apr 26 '23 at 12:28

0 Answers0