source: trunk/procs/legend_overlay.pro @ 68

Last change on this file since 68 was 45, checked in by ericg, 16 years ago

Minor modifs

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