1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
|
;
; This test verifys whether PLOT, PLOTS & OPLOT
; are able to plot USERSYM with color, fill & simsize
;
; Alain C., August 2017, at JSC during Harvey
;
; ----------------------------------------------------
; Modifications history :
;
; 2018-Oct-30 : AC.
; * merging "test_usersym.pro" in this file,
; renaming the function into as TEST_USERSYM_NAN
; * cleaning & adding some cases (+ ps & svg)
;
; ---------------------------------------------------
;
; I <<stole>> this snipet in "plotsym.pro" in IDLastro lib.
; and change it into a more general one
;
; Angle= is in Degree
; default Branches number is 5
;
pro SYM_STAR, branches, angle=angle, ratio=ratio, $
color=color, thick=thick, fill=fill, $
help=help, verbose=verbose, test=test
;
if N_PARAMS() EQ 0 then nb_tops=5 else nb_tops=branches
;
if N_ELEMENTS(angle) EQ 0 then angle=90
;
nbp=2*nb_tops
angles=(360. / nbp * FINDGEN(nbp+1) + angle) / !RADEG
;
r=angles*0
r[2*INDGEN(nb_tops+1)]=1.
cp5=COS(!pi/nb_tops)
r1=2. * cp5 - 1. / cp5
r[2*INDGEN(nb_tops)+1]=r1
r=r * SQRT(!pi/4.) * 2. / (1.+r1)
;
if KEYWORD_SET(ratio) then begin
maxi=MAX(r) & mini=MIN(r)
r=r/maxi
r[WHERE(r LT MEAN(r))]=ratio
endif
;
x=r * COS(angles)
y=r * SIN(angles)
;
USERSYM, x, y, fill=fill;, color=color, thick=thick, fill=fill
;
if KEYWORD_SET(test) then STOP
;
end
;
; ---------------------------------------------------
;
pro TEST_DEMO_SYM_STAR, fill=fill, ps=ps, svg=svg
;
soft=GDL_IDL_FL()
;
; SVG is only for GDL
if KEYWORD_SET(svg) AND (soft NE 'GDL') then begin
MESSAGE, /continue, 'SVG output not available in '+soft
return
endif
;
prefix=soft
if KEYWORD_SET(fill) then prefix=prefix+'_fill'
;
if KEYWORD_SET(SVG) or KEYWORD_SET(PS) then begin
save_p=!p
save_dname=!d.name
endif else begin
WINDOW, /free, title=GDL_IDL_FL(/title)+ROUTINE_NAME()
endelse
;
; SVG is only for GDL
if KEYWORD_SET(svg) then begin
set_plot, 'SVG'
device, file=prefix+'_'+ROUTINE_NAME(/lower)+'.svg'
endif
;
if KEYWORD_SET(PS) then begin
set_plot, 'PS'
device, file=prefix+'_'+ROUTINE_NAME(/lower)+'.ps'
endif
;
ratios=0.01+FINDGEN(11)/10.
;
if KEYWORD_SET(fill) then status=' : /fill' else status=' : no /fill'
;
PLOT, ratios, /nodata, xrange=[0, 16], yrange=[-0.2, 1.3], $
/ystyle, /xstyle, xtitle='number of branches', $
ytitle='value of ratio= keyword', $
title=GDL_IDL_FL(/title)+ROUTINE_NAME()+status
;
for rr=0, N_ELEMENTS(ratios)-1 do begin
for nbb=1, 15 do begin
SYM_STAR, nbb, ratio=ratios[rr], fill=fill
PLOTS, nbb, ratios[rr], PSYM=8, symsize=5
endfor
endfor
;
; defaut ratio
;
for nbb=1, 15 do begin
SYM_STAR, nbb
plots, nbb, 1.15, PSYM=8, symsize=5
endfor
;
if KEYWORD_SET(SVG) or KEYWORD_SET(PS) then begin
device, /close
;; reset the initial !p env.
!p=save_p
SET_PLOT, save_dname
endif
if KEYWORD_SET(test) then STOP
;
end
;
; ---------------------------------------------------
;
pro MY_USERSYM, type, color=color, thick=thick, fill=fill, $
help=help, verbose=verbose, test=test
;
if type EQ 'square' then begin
x=[0,1,1,0,0]
y=[0,0,1,1,0]
x=2.*(x-0.5)
y=2.*(y-0.5)
endif
;
if type EQ 'circle' then begin
nbp=35
A=FINDGEN(nbp) * (!PI*2/(nbp-1))
x=COS(a)
y=SIN(a)
endif
;
USERSYM, x, y, color=color, thick=thick, fill=fill
;
if KEYWORD_SET(demo) then plot, findgen(10), psym=8, syms=8
;
if KEYWORD_SET(test) then STOP
;
end
;
; ---------------------------------------------------
;
pro TEST_PLOTSYM, test=test
;
; we need to have the AstroLib in the PATH to run it
;
if ~EXECUTE('PLOTSYM, 0') then begin
MESSAGE, /continue, 'AstroLib should be in the PATH to run it'
return
endif
;
WINDOW, 0, title=GDL_IDL_FL(/title)+ROUTINE_NAME()
;
colors_list=['ff0000'x, '00ff00'x, 'ffffff'x, $
'ffff00'x, 'ff00ff'x, '00ffff'x]
;
plot, [-2,9], [0,5], /nodata, /xstyle, $
title='Testing symbols in PLOTSYM in IDL Astro', $
xtitle='index in PLOTSYM'
;
for ii=0, 8 do begin
jj=ii
PLOTSYM, ii
plots, jj, 1, psym=8
PLOTSYM, ii, color=colors_list[ii mod 6]
plots, jj, 2, psym=8
PLOTSYM, ii, color=colors_list[ii mod 6], /fill
plots, jj, 3, psym=8, symsize=2
PLOTSYM, ii, color=colors_list[ii mod 6], thick=3
plots, jj, 4, psym=8, symsize=3
endfor
;
XYOUTS, -1, 1, 'default size', align=0.5
XYOUTS, -1, 2, 'default size; colors', align=0.5
XYOUTS, -1, 3, 'size=2; colors + fill', align=0.5
XYOUTS, -1, 4, 'size=3; colors', align=0.5
;
if KEYWORD_SET(test) then STOP
;
end
;
; ---------------------------------------------------
;
; We must to be sure than PLOT, OPLOT & PLOTS do
; the same symbols (size, color, fill & thick)
;
pro TEST_OPLOTS_USERSYM, test=test
;
device, /decomposed
WINDOW, /free, title=GDL_IDL_FL(/title)+ROUTINE_NAME()
;
colors_list=['ff0000'x, '00ff00'x, '0000ff'x, $
'ffff00'x, 'ff00ff'x, '00ffff'x]
;
MY_USERSYM, 'square'
;
plot, INDGEN(9), REPLICATE(1,9), psym=8, symsize=2, $
xrange=[-2,9], yrange=[0,6], /xstyle, /ystyle, $
title='Testing USERSYM symbols (oplot, plots)'
xtitle='index in USERSYM '
plot, INDGEN(9), REPLICATE(1,9), psym=8, symsize=3,$
xrange=[-2,9], yrange=[0,6], /xstyle, /ystyle, $
/noerase
;
for ii=0, 8 do begin
color=colors_list[ii mod 6]
MY_USERSYM, 'square', color=color
;;
for jj=0, 5 do PLOTS, ii, 2, psym=8, symsize=jj+0.1
for jj=0, 5 do OPLOT, [ii], [3], psym=8, symsize=jj+0.1
;;
;; fill
MY_USERSYM, 'circle', color=color, /fill
;;
PLOTS, ii, 4, psym=8, symsize=4
OPLOT, [ii], [5], psym=8, symsize=4
;;
XYOUTS, -1, 1, 'PLOT', align=0.5
XYOUTS, -1, 2, 'PLOTS', align=0.5
XYOUTS, -1, 3, 'OPLOT', align=0.5
XYOUTS, -1, 4, 'PLOTS', align=0.5
XYOUTS, -1, 5, 'OPLOT', align=0.5
endfor
;
if KEYWORD_SET(test) then STOP
;
end
;
; ---------------------------------------------------
;
pro TEST_PLOT_USERSYM_COLOR, test=test
;
WINDOW, /free, title=GDL_IDL_FL(/title)+ROUTINE_NAME()
;
DEVICE, /decomposed
color='ff00ff'x
;
; first call : no color, done via PLOT/OPLOT
MY_USERSYM, 'circle'
;
; un bug : IDL != GDL
; la taille du symbole doit etre gérée via USERSYM
;
!p.multi=[0,2,0]
;
PLOT, FINDGEN(10), psym=8, thick=3, sym=4
OPLOT, FINDGEN(10), psym=8, thick=1, color=color
;
; second plot : color is passed using USERSYM
MY_USERSYM, 'circle', thick=2, color=color
plot, FINDGEN(10), psym=8, symsize=5
;
!p.multi=0
;
if KEYWORD_SET(test) then STOP
;
end
;
; ----------------------------------
; Alain Coulais, 28/11/2011
; Help tracking bug related to USERSYM
; this procedure is needed by the followin one : TEST_USERSYM_NAN
;
pro INTERNAL_PLOT, nbp, title=title, psym=psym, linestyle=linestyle, NaN=NaN
;
if N_PARAMS() EQ 0 then nbp=2
;
x=FINDGEN(nbp)/nbp
y=x
;
if KEYWORD_SET(NaN) and (nbp GT 4) then begin
x[4]=!values.f_nan
x[6]=!values.f_nan
x[7]=!values.f_nan
endif
;
plot, x,y, psym=psym, xrange=[-0.25,1.], yrange=[-0.25,1.], $
title=title, /xstyle, /ystyle
;
;print, '==========================================='
;
end
;
; ----------------------------------
;
pro TEST_PLOT_USERSYM_NAN, psym=psym, help=help, test=test
;
if KEYWORD_SET(help) then begin
print, 'pro TEST_USERSYM, psym=psym, help=help, test=test'
return
end
;
if N_ELEMENTS(psym) EQ 0 then psym=8
;
; square hat
UserSym, [-1, -0.5, -0.5, 0.5, 0.5, 1, -1], $
[-0.7, -0.7, 0.7, 0.7, -0.7, -0.7, -0.7]
;
!p.multi=[0,2,4]
xy=GET_SCREEN_SIZE()
WINDOW, /free, title=GDL_IDL_FL(/title)+ROUTINE_NAME(), $
xsize=FIX(xy[0]/3), ysize=FIX(xy[1]*0.9)
;
INTERNAL_PLOT, 1, psym=psym, title='1 point'
INTERNAL_PLOT, 2, psym=psym, title='2 points'
INTERNAL_PLOT, 3, psym=psym, title='3 points'
INTERNAL_PLOT, 3, psym=-psym, title='3 points + linestyle', line=2
;
INTERNAL_PLOT, 12, psym=psym, title='12 points'
INTERNAL_PLOT, 12, psym=-psym, title='12 points + linestyle', line=2
INTERNAL_PLOT, 12, psym=psym, title='NaN + 12 points', /nan
INTERNAL_PLOT, 12, psym=-psym, title='NaN + 12 points + linestyle', line=2, /nan
;
!p.multi=0
;
if KEYWORD_SET(test) then STOP
;
end
;
; ---------------------------------------------------
;
pro TEST_PLOT_USERSYM, no_exit=no_exit, $
help=help, test=test, verbose=verbose
;
if KEYWORD_SET(help) then begin
print, 'pro TEST_PLOT_USERSYM, no_exit=no_exit, $'
print, ' help=help, test=test, verbose=verbose'
return
endif
;
print, 'Just Visual tests'
;
rname=ROUTINE_NAME()
;
if ~CHECK_IF_DEVICE_IS_OK(rname, /force) then begin
if ~KEYWORD_SET(no_exit) then EXIT, status=77 else STOP
endif
;
;TEST_PLOTSYM
TEST_OPLOTS_USERSYM
TEST_PLOT_USERSYM_COLOR
TEST_PLOT_USERSYM_NAN
;
TEST_DEMO_SYM_STAR
TEST_DEMO_SYM_STAR, /fill
TEST_DEMO_SYM_STAR, /ps
TEST_DEMO_SYM_STAR, /ps, /fill
TEST_DEMO_SYM_STAR, /svg
TEST_DEMO_SYM_STAR, /svg, /fill
;
if KEYWORD_SET(test) OR KEYWORD_SET(no_exit) then STOP
;
if ~KEYWORD_set(no_exit) then begin
print, 'please wait one sec., Window to be delete ...'
WAIT, 1
while !d.window GE 0 do WDELETE
endif
;
end
|