fix 2D images for spam-ldic (flatten +1 in z in grid.py). Auto margin now base on min dimension and not max