Skip to content

plot_layout(guides = "collect") & theme(legend.position = 'bottom') printed a vertical legends #137

@seheeopark

Description

@seheeopark

I have two ggraphs to patch.

library(tidygraph)
library(ggraph) 

g1 <- gsi_wave1 %N>% 
  mutate(degree_sum = centrality_degree(mode = "all")) %>% 
  ggraph(layout = "kk") +
  geom_edge_link(aes(alpha = 0.5),
                 # Add arrow points 
                 arrow = arrow(length = unit(1, "mm")),
                 start_cap = circle(0.5, "mm"),
                 end_cap = circle(0.5, "mm")) +
  geom_node_point(aes(color = degree_sum,
                      alpha = 0.8)) + 
  scale_color_viridis(discrete = FALSE, option = "D") +
  theme_void() +
  ggtitle("GSI Network in wave 1 (2008-2010)")

g2 <- gsi_wave3 %N>% 
  mutate(degree_sum = centrality_degree(mode = "all")) %>% 
  ggraph(layout = "kk") +
  geom_edge_link(aes(alpha = 0.5),
                 # Add arrow points 
                 arrow = arrow(length = unit(1, "mm")),
                 start_cap = circle(0.5, "mm"),
                 end_cap = circle(0.5, "mm")) +
  geom_node_point(aes(color = degree_sum,
                      alpha = 0.8)) + 
  scale_color_viridis(discrete = FALSE, option = "D") +
  theme_void() +
  ggtitle("GSI Network in wave 3 (2015-2017)")

library(patchwork) 
g1 + g2 + plot_layout(guides = 'collect') & theme(legend.position = 'bottom')

The patched plot shows a collected legend in a vertical format.
plot_zoom

How can I get a collected legend in a horizontal format as in the individual graph?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions