Suggestion for a better layout of coda `plot_boxplots()` subplots
Description of feature
Hi, Thank you for your attention to the issue I raised last time. This time, I have a suggestion for layout of plot_boxplots(). In source code:
g = sns.FacetGrid(
plot_df,
col="Cell type",
sharey=False,
col_wrap=int(np.floor(np.sqrt(K))),
height=height,
aspect=aspect,
)
If we have 5 to 8 subplots, the np.floor() will make it 2 columns, if 10 to 15, 3 columns. Some users may like such a "long" layout, but some may not. Therefore, could you add an arguement to define subplot layout to choose "long" or "wide". If we choose "long",col_wrap=int(np.floor(np.sqrt(K))); if we choose βwideβ, col_wrap=int(np.ceil(np.sqrt(K))). Thanks for your attention gain! For better experience~
Thank you very much for the idea! We'll see what we can do but pull requests with such a change that outline the before and after are also welcome.
@shihsama: Do you have a public (small) dataset that could be used as an example for this issue? If you could provide some code for me to reproduce the 'long' plot you are talking about, I could tackle the implementation of the 'wide' version.
@mschilli87: Sorry for the delayed reply. I have not found a suitable public dataset. I had tested the code described above in my unpublished data. Because I prefer the 'wide' plot layout, I directly modified it in the source code of pertpy. Probably, the PBMC5k dataset is suitable. To produce specific number of cell types, we could subset the dataset with 'cell type' labels :)
As described above, for instance, assume that we have 5~8 cell types, int(np.floor(np.sqrt(K))) will produce 2 columns of subplots ("long" layout) while int(np.ceil(np.sqrt(K))) will produce 3 columns of subplots ("wide" layout). As for 4, 9, or 16 cell types (subplots), it's easy for us to get that it is a "square" layout :)
layout = layout ##assume a new arguement called "layout"
if layout == "wide":
col_wrap = int(np.ceil(np.sqrt(K)))
else:
col_wrap = int(np.floor(np.sqrt(K)))
g = sns.FacetGrid(
plot_df,
col="Cell type",
sharey=False,
col_wrap=col_wrap,
height=height,
aspect=aspect,
)
No worries. I wouldn't get to this before next week or the one after anyway. Until then it would really help me to have a small example I can copy/paste to generate the (current default) 'long' layout and ideally the 'wide' version generated by your modified code for the same dataset. This way, I have a very clear way of making sure I understood your suggestion correctly which will make it easier for me to add this more quickly.
If you don't have time, I think you feature request contains all information required to do it. But the more effort you put in, the higher this will be on my priority list. π
No worries. I wouldn't get to this before next week or the one after anyway. Until then it would really help me to have a small example I can copy/paste to generate the (current default) 'long' layout and ideally the 'wide' version generated by your modified code for the same dataset. This way, I have a very clear way of making sure I understood your suggestion correctly which will make it easier for me to add this more quickly.
If you don't have time, I think you feature request contains all information required to do it. But the more effort you put in, the higher this will be on my priority list. π
Not quite urgent and big issueππ€π»π€π»π€π».