Skip to content

Commit 226d840

Browse files
Merge pull request #7334 from EllangoK/master
X/Y/Z plot now saves sub grids if opts.grid_save and honors draw_legend
2 parents 07edf57 + fb58fa6 commit 226d840

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

scripts/xyz_grid.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,23 +286,24 @@ def index(ix, iy, iz):
286286
print("Unexpected error: draw_xyz_grid failed to return even a single processed image")
287287
return Processed(p, [])
288288

289-
grids = [None] * len(zs)
289+
sub_grids = [None] * len(zs)
290290
for i in range(len(zs)):
291291
start_index = i * len(xs) * len(ys)
292292
end_index = start_index + len(xs) * len(ys)
293293
grid = images.image_grid(image_cache[start_index:end_index], rows=len(ys))
294294
if draw_legend:
295295
grid = images.draw_grid_annotations(grid, cell_size[0], cell_size[1], hor_texts, ver_texts)
296-
297-
grids[i] = grid
296+
sub_grids[i] = grid
298297
if include_sub_grids and len(zs) > 1:
299298
processed_result.images.insert(i+1, grid)
300299

301-
original_grid_size = grids[0].size
302-
grids = images.image_grid(grids, rows=1)
303-
processed_result.images[0] = images.draw_grid_annotations(grids, original_grid_size[0], original_grid_size[1], title_texts, [[images.GridAnnotation()]])
300+
sub_grid_size = sub_grids[0].size
301+
z_grid = images.image_grid(sub_grids, rows=1)
302+
if draw_legend:
303+
z_grid = images.draw_grid_annotations(z_grid, sub_grid_size[0], sub_grid_size[1], title_texts, [[images.GridAnnotation()]])
304+
processed_result.images[0] = z_grid
304305

305-
return processed_result
306+
return processed_result, sub_grids
306307

307308

308309
class SharedSettingsStackHelper(object):
@@ -576,7 +577,7 @@ def cell(x, y, z):
576577
return res
577578

578579
with SharedSettingsStackHelper():
579-
processed = draw_xyz_grid(
580+
processed, sub_grids = draw_xyz_grid(
580581
p,
581582
xs=xs,
582583
ys=ys,
@@ -592,6 +593,10 @@ def cell(x, y, z):
592593
second_axes_processed=second_axes_processed
593594
)
594595

596+
if opts.grid_save and len(sub_grids) > 1:
597+
for sub_grid in sub_grids:
598+
images.save_image(sub_grid, p.outpath_grids, "xyz_grid", info=grid_infotext[0], extension=opts.grid_format, prompt=p.prompt, seed=processed.seed, grid=True, p=p)
599+
595600
if opts.grid_save:
596601
images.save_image(processed.images[0], p.outpath_grids, "xyz_grid", info=grid_infotext[0], extension=opts.grid_format, prompt=p.prompt, seed=processed.seed, grid=True, p=p)
597602

0 commit comments

Comments
 (0)