1 |
function [xyP,xyB]=def_subP(n,dxRed,dyRed,dxB,dyB); |
2 |
% [xyP,xyB]=def_subP(n,dxRed,dyRed,dxB,dyB); |
3 |
% |
4 |
% n = number of subplot in the page |
5 |
% dxRed = reduction of Horizon. size (x-dir) on the right side |
6 |
% dyRed = reduction of Vertical size (y-dir) splitted on both side |
7 |
% both dxRed,dyRed applies to all subplot |
8 |
% dxB,dyB :: scaling factor (relative to sub-plot size) of vertical colorbar |
9 |
% |
10 |
%- to use: [xyP,xyB]=def_subP(n*m,[dxRed,dyRed,dxB,dyB]); |
11 |
% and then, to replace subplot(nmj): |
12 |
% axes('position',xyP(j,:)); {make the plot} |
13 |
% BB=colorbar; set(BB,'Position',xyB(j,:)); |
14 |
|
15 |
% $Header: /u/gcmpack/MITgcm_contrib/jmc_script/def_subP.m,v 1.1 2014/09/30 22:10:26 jmc Exp $ |
16 |
% $Name: $ |
17 |
|
18 |
if nargin < 2, dxRed=0; end |
19 |
if nargin < 3, dyRed=0; end |
20 |
if nargin < 4, dxB=0.1; end |
21 |
if nargin < 5, dyB=0.9; end |
22 |
xyP=zeros(abs(n),4); xyB=xyP; |
23 |
|
24 |
if n == 24, |
25 |
%-- to replace subplot(64?): |
26 |
xyP(:,1)=0.12/4 ; xyP(:,2)=0.10/6; |
27 |
xyP(:,3)=0.84/4; ; xyP(:,4)=0.80/6; |
28 |
xyP([2:4:n],1)=xyP(21,1)+0.90/4; |
29 |
xyP([3:4:n],1)=xyP(21,1)+1.94/4; |
30 |
xyP([4:4:n],1)=xyP(21,1)+2.90/4; |
31 |
xyP( 1:4 ,2)=xyP(21,2)+4.86/6; |
32 |
xyP( 5:8 ,2)=xyP(21,2)+3.94/6; |
33 |
xyP( 9:12,2)=xyP(21,2)+2.86/6; |
34 |
xyP(13:16,2)=xyP(21,2)+1.94/6; |
35 |
xyP(17:20,2)=xyP(21,2)+0.90/6; |
36 |
%-- to add a vertical colorbar on the 6th plot without changing its size: |
37 |
%---------- |
38 |
end |
39 |
|
40 |
if n == 8, |
41 |
%-- to replace subplot(42?): |
42 |
xyP(:,1)=0.12/2 ; xyP(:,2)=0.10/4; |
43 |
xyP(:,3)=0.84/2 ; xyP(:,4)=0.80/4; |
44 |
xyP([2:2:n],1)=xyP(7,1)+0.5; |
45 |
xyP(1:2,2)=xyP(7,2)+2.85/4; |
46 |
xyP(3:4,2)=xyP(7,2)+1.90/4; |
47 |
xyP(5:6,2)=xyP(7,2)+0.95/4; |
48 |
%-- reduction size in X dir: |
49 |
xyP([2:2:n],1)=xyP([2:2:n],1)-dxRed*xyP(1,3); |
50 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
51 |
end |
52 |
|
53 |
if n == 6, |
54 |
%-- to replace subplot(32?): |
55 |
xyP(:,1)=0.12/2 ; xyP(:,2)=0.10/3; |
56 |
xyP(:,3)=0.84/2 ; xyP(:,4)=0.80/3; |
57 |
xyP([2:2:n],1)=xyP(5,1)+0.5; |
58 |
xyP(1:2,2)=xyP(5,2)+1.9/3; |
59 |
xyP(3:4,2)=xyP(5,2)+0.95/3; |
60 |
%-- reduction size in X dir: |
61 |
xyP([2:2:n],1)=xyP([2:2:n],1)-dxRed*xyP(1,3); |
62 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
63 |
%-- to add a vertical colorbar on the 6th plot without changing its size: |
64 |
%xyP(6,3)=xyP(6,3)*1.17; |
65 |
%--and after drawing the 6th plot:later: |
66 |
% BB=colorbar('vertical'); |
67 |
% pos=get(BB,'position'); |
68 |
% pos(1)=.49; pos(3)=pos(3)/5; pos(2)=pos(2)+pos(4)*.1; pos(4)=pos(4)*.8; |
69 |
% set(BB,'position',pos); |
70 |
%---------- |
71 |
end |
72 |
|
73 |
if n == 4, |
74 |
%-- to replace subplot(22?): |
75 |
% [xyP,xyB]=def_subP(6); axes('position',xyP(j,:)); {make the plot} |
76 |
% BB=colorbar; set(BB,'Position',xyB(j,:)); |
77 |
xyP(:,1)=0.10/2 ; xyP(:,2)=0.10/2; |
78 |
xyP(:,3)=0.80/2 ; xyP(:,4)=0.84/2; |
79 |
xyP([2:2:n],1)=xyP(1,1)+0.92/2; |
80 |
xyP(1:2,2)=xyP(n,2)+0.98/2; |
81 |
%-- reduction size in X dir: |
82 |
xyP([2:2:n],1)=xyP([2:2:n],1)-dxRed*xyP(1,3); |
83 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
84 |
%---------- |
85 |
end |
86 |
|
87 |
if n == -4, |
88 |
%-- to replace subplot(41?): [xyP]=def_subP(-4); axes('position',xyP(?,:)); |
89 |
xyP(:,1)=0.10 ; xyP(:,2)=0.16/4; |
90 |
xyP(:,3)=0.78 ; xyP(:,4)=0.72/4; |
91 |
%xyP(2:4,2)=xyP(1,2)+[1:3]*(0.98/4); %- put the 1rst @ the bottom |
92 |
xyP(1:3,2)=xyP(4,2)+[3:-1:1]*(0.98/4); %- put the 1rst @ the top |
93 |
%-- reduction size in X dir: |
94 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
95 |
%---------- |
96 |
end |
97 |
|
98 |
if n == 3, |
99 |
%-- to replace subplot(31?): [xyP]=def_subP(3); axes('position',xyP(?,:)); |
100 |
xyP(:,1)=0.10 ; xyP(:,2)=0.10/3; |
101 |
xyP(:,3)=0.84 ; xyP(:,4)=0.80/3; |
102 |
xyP(1,2)=xyP(n,2)+1.9/3; |
103 |
xyP(2,2)=xyP(n,2)+0.95/3; |
104 |
%-- reduction size in X dir: |
105 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
106 |
%---------- |
107 |
end |
108 |
|
109 |
if n == -3, |
110 |
%-- to replace subplot(13?): [xyP]=def_subP(-3); axes('position',xyP(?,:)); |
111 |
xyP(:,1)=0.10/3 ; xyP(:,2)=0.10; |
112 |
xyP(:,3)=0.80/3 ; xyP(:,4)=0.84; |
113 |
xyP(2,1)=xyP(1,1)+0.95/3; |
114 |
xyP(3,1)=xyP(1,1)+1.9/3; |
115 |
%-- reduction size in X dir: |
116 |
%xyP(2,1)=xyP(2,1)-dxRed*xyP(1,3); |
117 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
118 |
%---------- |
119 |
end |
120 |
|
121 |
if n == 2, |
122 |
%-- to replace subplot(21?): [xyP]=def_subP(2); axes('position',xyP(?,:)); |
123 |
xyP(:,1)=0.10 ; xyP(:,2)=0.10/2; |
124 |
xyP(:,3)=0.84 ; xyP(:,4)=0.80/2; |
125 |
xyP(1,2)=xyP(n,2)+0.98/2; |
126 |
%-- reduction size in X dir: |
127 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
128 |
%---------- |
129 |
end |
130 |
|
131 |
if n == -2, |
132 |
%-- to replace subplot(12?): [xyP]=def_subP(-2); axes('position',xyP(?,:)); |
133 |
xyP(:,1)=0.10/2 ; xyP(:,2)=0.10; |
134 |
xyP(:,3)=0.80/2 ; xyP(:,4)=0.84; |
135 |
xyP(2,1)=xyP(1,1)+0.92/2; |
136 |
%-- reduction size in X dir: |
137 |
%xyP(2,1)=xyP(2,1)-dxRed*xyP(1,3); |
138 |
xyP(:,3)=xyP(:,3)*(1-dxRed); |
139 |
%---------- |
140 |
end |
141 |
|
142 |
%- reduce size in Y by dyRed fraction: |
143 |
xyP(:,2)=xyP(:,2)+xyP(:,4)*dyRed/2; |
144 |
xyP(:,4)=xyP(:,4)*(1.-dyRed); |
145 |
|
146 |
%- colorbar position |
147 |
xyB(:,1)=xyP(:,1)+xyP(:,3)*(1+dxB); |
148 |
xyB(:,2)=xyP(:,2)+xyP(:,4)*(1-dyB)/2; |
149 |
xyB(:,3)=xyP(:,3)*dxB; |
150 |
xyB(:,4)=xyP(:,4)*dyB; |
151 |
|
152 |
return |