Issue
Does Matplotlib have a built-in column wrap method?
The following image shows an analogous method in Seaborn's catplot.
Purpose...
I have a function that plots N images with plt.imshow()
. The number of images can varies, from about 20 to 50. I am using subplots to tile them, and would like to automate the number of 'rows' by using a wrapping function such as the one mentioned above.
Solution
I don't think there's built-in support for a column wrapper in matplotlib.
In fact, if you look at the Seaborn source code for FacetGrid, you can see that the author uses a simple calculation based on the col_wrap parameter to build the subplot layout.
if col_wrap is not None:
if row is not None:
err = "Cannot use `row` and `col_wrap` together."
raise ValueError(err)
ncol = col_wrap
nrow = int(np.ceil(len(col_names) / col_wrap))
https://github.com/mwaskom/seaborn/blob/master/seaborn/axisgrid.py#L418
Answered By - privard
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.