[2] | 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) |
---|
[36] | 4 | IF debug_w THEN print, ' in legend_overlay, iover=', iover |
---|
[2] | 5 | ; |
---|
| 6 | ; decode legend format from command line (see def_work cmdi.proj) |
---|
| 7 | ; |
---|
[37] | 8 | leg_pos = strmid(leg_format, 0, 2); (UL=-1, UR, LR, LL) |
---|
[2] | 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 |
---|
[36] | 17 | IF debug_w THEN print, 'leg_format, leg_pos: ', leg_format, leg_pos |
---|
| 18 | IF debug_w THEN print, 'jpt, jptmax, nb_cycles: ', jpt, jptmax, nb_cycles |
---|
[2] | 19 | |
---|
| 20 | ; legend line text |
---|
| 21 | leg_txt = '' |
---|
| 22 | IF strpos(txt_format, 'E') NE -1 THEN leg_txt = leg_txt+cmd.exp+' ' |
---|
| 23 | IF strpos(txt_format, 'V') NE -1 THEN leg_txt = leg_txt+cmd.var+' ' |
---|
| 24 | IF strpos(txt_format, 'L') NE -1 THEN leg_txt = leg_txt+field.legend+' ' |
---|
| 25 | IF strpos(txt_format, 'U') NE -1 THEN leg_txt = leg_txt+'('+field.units+') ' |
---|
| 26 | IF strpos(txt_format, 'B') NE -1 THEN leg_txt = leg_txt+legz+' ' |
---|
| 27 | |
---|
[36] | 28 | CASE plttyp OF |
---|
[45] | 29 | 'yfx': leg_txt = coeff_txt+coefflu_txt+coeffm_txt |
---|
[36] | 30 | ELSE: |
---|
| 31 | END |
---|
[2] | 32 | |
---|
[36] | 33 | |
---|
[2] | 34 | IF 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 | |
---|
| 39 | CASE 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 |
---|
| 64 | ENDCASE |
---|
| 65 | |
---|
| 66 | ; size between end of line and text (% of window size) |
---|
| 67 | delta_txt = 0.01 |
---|
| 68 | px_tr = px_2r+delta_txt |
---|
| 69 | px_tl = px_2l+delta_txt |
---|
| 70 | |
---|
[39] | 71 | IF plttyp EQ 'yfx' THEN px_tl = 0.04 |
---|
| 72 | |
---|
[2] | 73 | IF debug_w THEN print, ' nwin_tot, n_leg_max = ', nwin_tot, n_leg_max |
---|
| 74 | |
---|
| 75 | delta = 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 |
---|
| 77 | IF strmid(leg_pos, 0, 1) EQ 'L' THEN BEGIN ; (L)ower |
---|
| 78 | y_leg = minc+(nover-float(iover)+0.5)*delta |
---|
| 79 | ENDIF ELSE BEGIN ; (U)pper |
---|
| 80 | y_leg = maxc-(float(iover))*delta |
---|
| 81 | ENDELSE |
---|
| 82 | ; special case of plt1d,'z' |
---|
| 83 | |
---|
| 84 | IF 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 |
---|
| 94 | ENDIF |
---|
| 95 | y_leg_t = y_leg*y_scale_txt |
---|
| 96 | ; case pltt plt1d |
---|
| 97 | IF debug_w THEN print, 'size(time) ', size(time) |
---|
[36] | 98 | IF debug_w THEN print, 'minc/maxc =', minc, maxc |
---|
| 99 | |
---|
[2] | 100 | CASE plttyp OF |
---|
| 101 | 'pltt': BEGIN |
---|
[37] | 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 |
---|
[2] | 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 |
---|
[37] | 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 |
---|
[2] | 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 |
---|
[36] | 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 |
---|
[37] | 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 |
---|
[36] | 147 | x_leg_t = xmin+px_tl*x_dim |
---|
| 148 | ENDELSE |
---|
| 149 | END |
---|
[2] | 150 | ENDCASE |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | leg = [y_leg, y_leg] |
---|
| 154 | |
---|
| 155 | ; draw line |
---|
| 156 | overc_l = strmid(overc,7, strlen(overc)-1) |
---|
| 157 | CASE 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' |
---|
[18] | 163 | printf, nulhis, strcompress(pltcmd) |
---|
[2] | 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) |
---|
[18] | 170 | printf, nulhis, strcompress(pltcmd) |
---|
[2] | 171 | res = execute(pltcmd) |
---|
| 172 | END |
---|
[36] | 173 | ELSE: |
---|
[2] | 174 | ENDCASE |
---|
| 175 | IF debug_w THEN print, overc_l |
---|
| 176 | ; draw text |
---|
| 177 | xyouts, x_leg_t, y_leg_t, leg_txt, charsize = txt_ft_size, color = string(line_color(iover-1)), charthick = 1., font = 1. |
---|