fig2tiles.m

From Spinach Documentation Wiki
Jump to: navigation, search

Combines Matlab figure files into a single tiled figure. The shape of the fig_files cell array sets the tile grid: the entry in row m and column n of the array becomes the tile in row m and column n of the merged figure. A new figure of the requested pixel size is created off the screen with kfigure.m, a tiled layout with loose spacing and padding is placed into it, one placeholder axes is allocated for every tile, and the outer positions of those placeholders are recorded after a drawnow.

Each source file is then opened invisibly with openfig.m and its top-level children are copied into the merged figure. A source figure that already contains exactly one tiled layout is copied wholesale, and the copied layout is assigned to the destination tile. A source figure with no top-level axes has its chart objects copied and assigned to the tile directly. A source figure whose top-level axes overlap each other - the test is an overlap of the inner axes rectangles by more than sqrt(eps) in both directions - is copied into a uipanel sized to the outer rectangle of the placeholder tile, and a SizeChangedFcn callback keeps that panel aligned with the placeholder when the merged figure is resized. In the remaining case the centres of the source axes are clustered with uniquetol into a grid of rows and columns, the grid is refined from the densest source row and the densest source column, a nested tiled layout of that size is created inside the destination tile, and each copied axes is given the tile and the tile span that match its position in the source figure. Legends and colorbars are left out of the tile assignment, and axes colour maps are copied over when the source and the destination axes counts agree. An error at any point deletes both the source and the incomplete destination figure and is rethrown.

Syntax

    [fig_obj,tile_obj]=fig2tiles(fig_files,fig_size)

Parameters

    fig_files - cell array of character strings containing
                Matlab *.fig file names

    fig_size  - width and height of the merged figure in scr-
                een pixels, a two-element row vector

Outputs

    fig_obj  - handle of the new Matlab figure

    tile_obj - handle of the tiled layout object

Notes

Note: tile geometry is measured at the moment the layout is created, and so the figure must already have its final size at that point. Matlab shrinks a visible figure to fit the display; the merge therefore runs off the screen, and the figure is only shown at the end, at the visibility the caller has set as the figure default, when its outer extent fits. Figures bigger than the screen stay invisible and must be written out with exportgraphics.m or print.m; if they are reopened later with openfig.m, Matlab refits them to the screen and the size requested here is lost.

Panel letters drawn by kletter.m in the source figures are re-applied to the retiled axes, so that their offsets from the plot box edges are those of kletter.m.

All files listed in fig_files must exist and must have the *.fig extension; a source figure that contains no graphics objects, or no objects that can be placed into a tile, raises an error.

See also

kfigure.m, scale_figure.m, plot_2d.m, stack_2d.m, Kernel utilities

Version 2.13, authors: Ilya Kuprov