/[MITgcm]/MITgcm_contrib/jmc_script/def_subP.m
ViewVC logotype

Contents of /MITgcm_contrib/jmc_script/def_subP.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Sep 30 22:10:26 2014 UTC (9 years, 7 months ago) by jmc
Branch: MAIN
avoid using "subplot"

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

  ViewVC Help
Powered by ViewVC 1.1.22