Update subplot arrangement to support non-uniform grids

Summary: Previously, grids where the columns don't divide the number of plots evenly would error. Now, there'll just be a sparse last row.

Reviewed By: bottler

Differential Revision: D25069236

fbshipit-source-id: 9d2fd62f3d39bfebc07ce0a41718621fa69d6057
This commit is contained in:
Amitav Baruah 2020-11-18 15:45:42 -08:00 committed by Facebook GitHub Bot
parent 5fb63b4520
commit 6c2fc685de

View File

@ -692,10 +692,9 @@ def _gen_fig_with_subplots(batch_size: int, ncols: int, subplot_titles: List[str
Returns: Returns:
Plotly figure with ncols subplots per row, and batch_size subplots. Plotly figure with ncols subplots per row, and batch_size subplots.
""" """
if batch_size % ncols != 0:
msg = "ncols is invalid for the given mesh batch size."
warnings.warn(msg)
fig_rows = batch_size // ncols fig_rows = batch_size // ncols
if batch_size % ncols != 0:
fig_rows += 1 # allow for non-uniform rows
fig_cols = ncols fig_cols = ncols
fig_type = [{"type": "scene"}] fig_type = [{"type": "scene"}]
specs = [fig_type * fig_cols] * fig_rows specs = [fig_type * fig_cols] * fig_rows