Skip to content
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

Labels in plot_grid() seemed not affected by byrow #199

Open
evanliu3594 opened this issue Jan 15, 2024 · 2 comments · May be fixed by #203
Open

Labels in plot_grid() seemed not affected by byrow #199

evanliu3594 opened this issue Jan 15, 2024 · 2 comments · May be fixed by #203

Comments

@evanliu3594
Copy link

Labels are always attached by row.

p_list <- mtcars %>% split(.$gear) %>% map(~ggplot(.x,aes(x = mpg, y = disp)) + geom_point())
plot_grid(plotlist = p_list, ncol = 2, labels = names(p_list), byrow = F)

image

p_list["4"]

image

@Doubt-0KB
Copy link

If you don't mind adding more code, you can write it like this.

p_list <- mtcars %>% split(.$gear) %>% map(~ggplot(.x,aes(x = mpg, y = disp)) + geom_point())
p_list_label <- c(t(matrix(c(names(p_list), rep(NA, (2 * 2) - length(p_list))), nrow = 2, byrow = FALSE)))
plot_grid(plotlist = p_list, ncol = 2, labels = p_list_label, byrow = F)

image

I wrote this code with reference to the code which is at line181 in plot_grid.R.

@evanliu3594
Copy link
Author

If you don't mind adding more code, you can write it like this.

p_list <- mtcars %>% split(.$gear) %>% map(~ggplot(.x,aes(x = mpg, y = disp)) + geom_point())
p_list_label <- c(t(matrix(c(names(p_list), rep(NA, (2 * 2) - length(p_list))), nrow = 2, byrow = FALSE)))
plot_grid(plotlist = p_list, ncol = 2, labels = p_list_label, byrow = F)

image

I wrote this code with reference to the code which is at line181 in plot_grid.R.

Thanks for your solution, I'd like to use it if I have to adjust the label order manually. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants