-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plot_layout(guides = "collect") & theme(legend.position = 'bottom') printed a vertical legends #137
Comments
I think that the color scale should be between the same values in order to be collected, this also applies to the alpha (and probably should use the same line type in both plots). BTW you didn't show the code used to compose these plots and I couldn't run the code you have because I don't know how to generate |
Hello Lluís Two graphs shared the same alpha for nodes and edges, and they are indeed collected. What I am curious about is why the collected 'bottom' legend takes a vertical format. library(patchwork)
g1 + g2 Let me share the network data here (I had to delete other detailed node information, but the nodes and edges are the same): gsi_network.zip
Thank you for your time and help. |
Interestingly alpha and edge link gott collected but not the color. However, now that I look closer to the code if you have a fixed aesthetic you should use it outside the g1 <- gsi_wave1 %N>%
mutate(degree_sum = centrality_degree(mode = "all")) %>%
ggraph(layout = "kk") +
geom_edge_link(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(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)") Surprisingly I got another error when I change the order: g1 + g2 & theme(legend.position = "bottom") + plot_layout(guides = 'collect')
Error: Don't know how to add RHS to a theme object Maybe the difference is that these plots are of class |
Hello Lluís, The new error you are getting is from adding the - Josh |
Is there a solution to the initial question? Specifically, how to achieve two horizontal legends "collected" at the bottom, but next to each other instead of aligned vertically?. |
This issue is closed since 2020 but not resolved yet. Quick answer :
|
I have two ggraphs to patch.
The patched plot shows a collected legend in a vertical format.
How can I get a collected legend in a horizontal format as in the individual graph?
The text was updated successfully, but these errors were encountered: