source: trunk/procs/legend_overlay.pro @ 162

Last change on this file since 162 was 162, checked in by pinsard, 15 years ago

start to modify unformal header to idldoc 2. header syntax

File size: 5.8 KB
Line 
1;+
2;
3; @version
4; $Id$
5;
6;-
7; print legend (line + text) in pltt type 't' (called from plt_map)
8                                ; domain_y = minc,maxc /
9                                ; domaint=time(0), time(jptmax-1)
10IF debug_w THEN print, ' in legend_overlay, iover=', iover
11;
12; decode legend format from command line (see def_work cmdi.proj)
13;
14leg_pos = strmid(leg_format, 0, 2); (UL=-1, UR, LR, LL)
15IF strpos(leg_format, '_') NE -1 THEN BEGIN
16   txt_format = strmid(leg_format, 3, strlen(leg_format))
17ENDIF ELSE BEGIN
18   txt_format = default_txt_format
19ENDELSE
20
21; when there is more than one seasonal cycle
22jptmax = jpt * nb_cycles
23IF debug_w THEN print, 'leg_format, leg_pos: ', leg_format,  leg_pos
24IF debug_w THEN print, 'jpt, jptmax, nb_cycles: ', jpt,  jptmax, nb_cycles
25
26; legend line text
27leg_txt = ''
28IF strpos(txt_format, 'E') NE -1 THEN leg_txt = leg_txt+cmd.exp+' '
29IF strpos(txt_format, 'V') NE -1 THEN leg_txt = leg_txt+cmd.var+' '
30IF strpos(txt_format, 'L') NE -1 THEN leg_txt = leg_txt+field.legend+' '
31IF strpos(txt_format, 'U') NE -1 THEN leg_txt = leg_txt+'('+field.units+') '
32IF strpos(txt_format, 'T') NE -1 THEN leg_txt = leg_txt+cmd.date1+' '
33IF strpos(txt_format, 'B') NE -1 THEN leg_txt = leg_txt+legz+' '
34IF strpos(txt_format, 'S') NE -1 THEN leg_txt = leg_txt+' std='+stddev_txt+' '
35
36CASE plttyp OF
37   'yfx': leg_txt = coeff_txt+coefflu_txt+coeffm_txt
38   ELSE:
39END 
40
41
42IF debug_w THEN print, ' leg_pos, leg_txt = ', leg_pos,  leg_txt
43; px_n = percentage of window size function of number of windows
44; initial percentage px_1r is function of strlen(leg_txt)
45; n_leg_max = max number of lines in legend box
46
47CASE nwin_tot OF
48   1: BEGIN
49      px_1r = float(93-strlen(leg_txt))/100
50      px_2r = px_1r+0.05 & px_1l = 0.03 & px_2l = 0.08
51      n_leg_max = 20 & txt_ft_size = 1.4 & y_scale_txt = 0.998
52      delta_txt_add = 0.05
53   END
54   2: BEGIN
55      px_1r = float(84-strlen(leg_txt))/100
56      px_2r = px_1r+0.1 & px_1l = 0.03 & px_2l = 0.13
57      n_leg_max = 20 & txt_ft_size = 1.4 & y_scale_txt = 0.995
58      delta_txt_add = 0.07
59   END
60   3: BEGIN
61      px_1r = float(84-strlen(leg_txt))/100
62      px_2r = px_1r+0.1 & px_1l = 0.03 & px_2l = 0.13
63      n_leg_max = 15 & txt_ft_size = 1.2 & y_scale_txt = 0.995
64      delta_txt_add = 0.1
65   END
66   ELSE: BEGIN
67      px_1r = float(75-strlen(leg_txt))/100
68      px_2r = px_1r+0.1 & px_1l = 0.03 & px_2l = 0.13
69      n_leg_max = 15 & txt_ft_size = 1.1 & y_scale_txt = 0.995
70      delta_txt_add = 0.1
71   END
72ENDCASE
73
74; size between end of line and text (% of window size)
75delta_txt = 0.01
76px_tr = px_2r+delta_txt
77px_tl = px_2l+delta_txt
78
79IF plttyp EQ 'yfx' THEN px_tl = 0.04
80
81IF debug_w THEN print, ' nwin_tot, n_leg_max = ', nwin_tot, n_leg_max
82
83delta = float(maxc-minc)/(float(n_leg_max)+2.)
84; position of legend line (x_leg_1 to 2,y_leg) and text x_leg_t,; y_leg_t
85IF strmid(leg_pos, 0, 1) EQ 'L' THEN BEGIN ; (L)ower
86   y_leg = minc+(nover-float(iover)+0.5)*delta
87ENDIF ELSE BEGIN ; (U)pper
88   y_leg = maxc-(float(iover))*delta
89ENDELSE
90; special case of plt1d,'z'
91
92IF plttyp EQ 'plt1d' AND plt1dtyp EQ 'z' THEN  BEGIN
93   ymin = boite_plt1d(4)
94   ymax = boite_plt1d(5)
95   y_dim = boite_plt1d(5)-boite_plt1d(4)
96   delta = y_dim/(float(n_leg_max)+2.)
97   IF strmid(leg_pos, 0, 1) EQ 'L' THEN BEGIN ; (L)ower
98      y_leg = ymax-(nover-float(iover)+0.5)*delta
99   ENDIF ELSE BEGIN             ; (U)pper
100      y_leg = ymin+(float(iover)+0.5)*delta
101   ENDELSE
102ENDIF 
103y_leg_t = y_leg*y_scale_txt
104; case pltt plt1d
105IF debug_w THEN print,  'size(time) ',  size(time)
106IF debug_w THEN print,  'minc/maxc =', minc, maxc
107
108CASE plttyp OF
109   'pltt': BEGIN
110      IF strmid(leg_pos, 1, 1) EQ 'R' THEN BEGIN ; (R)ight
111         x_leg_1 = time(floor(px_1r*(jptmax-1)))
112         x_leg_2 = time(floor(px_2r*(jptmax-1)))
113         x_leg_t = time(floor(px_tr*(jptmax-1)))
114      ENDIF ELSE BEGIN          ; (L)eft
115         x_leg_1 = time(floor(px_1l*(jptmax-1)))
116         x_leg_2 = time(floor(px_2l*(jptmax-1)))
117         x_leg_t = time(floor(px_tl*(jptmax-1)))
118      ENDELSE
119   END
120   'plt1d': BEGIN
121      CASE plt1dtyp OF
122         'x': BEGIN
123            xmin = boite_plt1d(0)
124            x_dim = boite_plt1d(1)-boite_plt1d(0)
125         END
126         'y': BEGIN
127            xmin = boite_plt1d(2)
128            x_dim = boite_plt1d(3)-boite_plt1d(2)
129         END
130         'z': BEGIN
131            xmin = minc
132            x_dim = maxc-minc
133         END
134         ELSE:
135      ENDCASE
136      IF strmid(leg_pos, 1, 1) EQ 'R' THEN BEGIN ; (R)ight
137         x_leg_1 = xmin+px_1r*x_dim
138         x_leg_2 = xmin+px_2r*x_dim
139         x_leg_t = xmin+px_tr*x_dim
140      ENDIF ELSE BEGIN          ; (L)eft
141         x_leg_1 = xmin+px_1l*x_dim
142         x_leg_2 = xmin+px_2l*x_dim
143         x_leg_t = xmin+px_tl*x_dim
144      ENDELSE
145   END
146   'yfx': BEGIN
147      x_leg_1 = -1.e10
148      x_leg_2 = -1.e10
149      IF debug_w THEN print,  'minc2/maxc2 =', minc2, maxc2
150      xmin = minc2
151      x_dim = maxc2-minc2
152      IF strmid(leg_pos, 1, 1) EQ 'R' THEN BEGIN ; (R)ight
153         x_leg_t = xmin+px_tr*x_dim
154      ENDIF ELSE BEGIN          ; (L)eft
155         x_leg_t = xmin+px_tl*x_dim
156      ENDELSE
157   END
158ENDCASE
159
160
161leg = [y_leg, y_leg]
162
163; draw line
164overc_l = strmid(overc,7, strlen(overc)-1)
165CASE plttyp OF
166   'pltt': BEGIN
167      time = [x_leg_1, x_leg_2]
168      jpt_o = jpt
169      jpt = 2
170      pltcmd = 'pltt, leg, '+''''+'t'+''''+overc_l+ ',ov1d=1'+',/noerase'
171      printf, nulhis, strcompress(pltcmd)
172      res = execute(pltcmd)
173      jpt = jpt_o
174   END
175   'plt1d': BEGIN
176      x_leg = [x_leg_1, x_leg_2]
177      pltcmd = 'oplot,x_leg,leg'+colov+line_thick_txt+', LINESTYLE='+string(line_style(iover-1)-1)
178      printf, nulhis, strcompress(pltcmd)
179      res = execute(pltcmd)
180   END
181   ELSE:
182ENDCASE
183IF debug_w THEN print, overc_l
184; draw text
185xyouts, x_leg_t, y_leg_t, leg_txt, charsize = txt_ft_size, color = string(line_color(iover-1)), charthick = 1., font = 1.
Note: See TracBrowser for help on using the repository browser.