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