123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- function PanelHandles = MultiPanel(FigureHandle, Dimension, Margins, InterPanelSpacing, LetterSize, PanelLetters, LetterFontSize)
- if ~exist('LetterFontSize', 'var')
- LetterFontSize = 12;
- end
- NumberOfPanelRows = Dimension(1);
- NumberOfPanelColumns = Dimension(2);
- RightMargin = Margins(2);
- LeftMargin = Margins(1);
- TopMargin = Margins(4);
- BottomMargin = Margins(3);
- if sum(LetterSize > 0) % have letter axes size, stuck between other spaces
- LetterWidth = LetterSize(1);
- LetterHeight = LetterSize(2);
- else % have letter axes position, overlaying other spaces
- LetterWidth = 0;
- LetterHeight = 0;
- LetterX = LetterSize(1);
- LetterY = LetterSize(2);
- end
- InterPanelWidth = InterPanelSpacing(1);
- InterPanelHeight = InterPanelSpacing(2);
- PanelWidth = (1 - (LeftMargin + NumberOfPanelColumns*LetterWidth + (NumberOfPanelColumns - 1) * InterPanelWidth + RightMargin)) / NumberOfPanelColumns;
- PanelHeight = (1 - (BottomMargin + (NumberOfPanelRows - 1) * InterPanelHeight + NumberOfPanelRows * LetterHeight + TopMargin)) / NumberOfPanelRows;
- PanelHandles = nan(NumberOfPanelRows, NumberOfPanelColumns);
- figure(FigureHandle)
- for Row = 1:NumberOfPanelRows
- for Column = 1:NumberOfPanelColumns
- % create panel
- PanelHandles(Row, Column) = axes('Position', [LeftMargin + LetterWidth + (Column - 1) * (LetterWidth + InterPanelWidth + PanelWidth) ...
- BottomMargin + (NumberOfPanelRows - Row) * (LetterHeight + InterPanelHeight + PanelHeight) ...
- PanelWidth PanelHeight]);
- % put panel letter (if desired)
- if ~isempty(PanelLetters{Row, Column})
- if sum(LetterSize > 0)
- axes('Position', [LeftMargin + (Column - 1) * (LetterWidth + InterPanelWidth + PanelWidth) ...
- BottomMargin + PanelHeight + (NumberOfPanelRows - Row) * (LetterHeight + InterPanelHeight + PanelHeight) ...
- LetterWidth LetterHeight], 'visible', 'off')
- else
- MainAxesPosition = get(PanelHandles(Row, Column), 'Position');
- axes('Position', [MainAxesPosition(1) + LetterX, MainAxesPosition(2) + MainAxesPosition(4) - LetterY, eps, eps])
- end
- set(gca, 'visible', 'off')
- text(0.5, 0.5, PanelLetters{Row, Column}, 'FontSize', LetterFontSize, 'VerticalAlign', 'middle', 'HorizontalAlign', 'center', 'FontWeight', 'bold')%
- end
- end
- end
|