time | Calls | line |
|---|
| | 656 | function addAxesToGrid(ax, nRows, nCols, row, col, position, plotId)
|
< 0.001 | 4 | 657 | p = ax.Parent;
|
< 0.001 | 4 | 658 | grid = getappdata(p, 'SubplotGrid');
|
< 0.001 | 4 | 659 | if isempty(grid)
|
0.005 | 1 | 660 | grid = gobjects(nRows,nCols);
|
< 0.001 | 4 | 661 | end
|
| | 662 |
|
| | 663 | % add SubplotListenersManager to p
|
< 0.001 | 4 | 664 | if ~isappdata(p,'SubplotListenersManager')
|
0.012 | 1 | 665 | lm = matlab.graphics.internal.SubplotListenersManager(nRows*nCols);
|
| | 666 | % create an empty filed so that other tests wont complain
|
< 0.001 | 1 | 667 | setappdata(p,'SubplotListeners',[]);
|
< 0.001 | 3 | 668 | else
|
< 0.001 | 3 | 669 | lm=getappdata(p,'SubplotListenersManager');
|
< 0.001 | 4 | 670 | end
|
0.012 | 4 | 671 | lm.addToListeners(ax,[]);
|
< 0.001 | 4 | 672 | setappdata(p,'SubplotListenersManager',lm);
|
| | 673 |
|
| | 674 | % add SubplotDeleteListenersManager to axes
|
< 0.001 | 4 | 675 | if ~isappdata(ax,'SubplotDeleteListenersManager')
|
0.003 | 4 | 676 | dlm = matlab.graphics.internal.SubplotDeleteListenersManager();
|
0.001 | 4 | 677 | dlm.addToListeners(ax);
|
< 0.001 | 4 | 678 | setappdata(ax,'SubplotDeleteListenersManager',dlm);
|
< 0.001 | 4 | 679 | end
|
| | 680 |
|
< 0.001 | 4 | 681 | setappdata(ax,'SubplotGridLocation',{nRows,nCols,plotId})
|
< 0.001 | 4 | 682 | setappdata(ax, 'SubplotPosition', position); % normalized
|
< 0.001 | 4 | 683 | subplotlayoutInvalid(handle(ax), [], p);
|
| | 684 |
|
| | 685 | %when subplot is not in a single grid cell for the current grid,
|
| | 686 | %don't add it to the auto-layout
|
0.001 | 4 | 687 | if any(size(grid) ~= [nRows, nCols]) ... %active grid shape does not match n,m
|
| 4 | 688 | || length(row) ~= 1 || length(col) ~= 1 ... %multi-cell subplot
|
| 4 | 689 | || round(row) ~= row || round(col) ~= col ... %non-integer cell specified
|
| 4 | 690 | || grid(row + 1, col + 1) == ax %axes is already in cell m,n,p
|
| | 691 | addAxesToSpanGrid(ax, nRows, nCols, row, col);
|
| | 692 | return
|
< 0.001 | 4 | 693 | end
|
| | 694 |
|
| | 695 | % only add axes to grid if it doesn't span multiple columns or rows
|
< 0.001 | 4 | 696 | grid(row + 1, col + 1) = ax;
|
< 0.001 | 4 | 697 | setappdata(p, 'SubplotGrid', grid)
|
0.001 | 4 | 698 | end
|
Other subfunctions in this file are not included in this listing.