wilkelab / cowplot

cowplot: Streamlined Plot Theme and Plot Annotations for ggplot2
https://wilkelab.org/cowplot/
701 stars 84 forks source link

Issue 161: by column with plot_grid #163

Closed BrianLang closed 4 years ago

BrianLang commented 4 years ago

closes #161

BrianLang commented 4 years ago

Somehow I'm still figuring out how to do all of this. Was there a way to do what you asked (merge to master, fix things, commit, and push) without opening a new pull request?

clauswilke commented 4 years ago

Yes, you can just keep pushing commits and github automatically sees them and updates the PR. No problem though, we can work with this one.

clauswilke commented 4 years ago

Sorry, one more issue. Can you try your plot reordering code for a case where num_plots is less than rows * cols? I think your matrix() call will create a warning, and you should be able to fix this by padding 1:num_plots with NAs. Maybe this will work: c(1:num_plots, rep(NA, rows * cols - num_plots))

BrianLang commented 4 years ago

You were correct that having num_plots < cols * rows produces warnings and issues, specifically that matrix recycles inputs. So I've added your suggestion of padding with c(1:num_plots, rep(NA, rows * cols - num_plots)) and it looks correct now.

It also is coincidental the case that the previous visual test gave a false "valid" for dropping the last NULL, so I've updated it to something that wouldn't pass given the previous implementation.

expect_doppelganger("colwise arranging",
   plot_grid(p1, NULL, p2, p3, NULL, byrow = FALSE) + theme_map() # add theme_map() for plot title
 )
clauswilke commented 4 years ago

Thanks!

BrianLang commented 4 years ago

Woooo! First merged pull request! Thanks for your help :-)

Dicky3333 commented 4 years ago

Thanks Claus and Brian for working on this request. I updated the cowplot package withinstall.package("cowplot"). But the plot_grid() method doesn't seem to have the new 'byrow' parameter. I'd appreciate if you could tell me how to get the updated package.

clauswilke commented 4 years ago

You'll have to install the development version.

remotes::install_github("wilkelab/cowplot")