Shade areas in POLAR_CONTOUR [message #93575] |
Wed, 24 August 2016 15:34  |
Matteo
Messages: 28 Registered: August 2011
|
Junior Member |
|
|
Hi,
the snippet of code posted below produces a polar contour of a "target" plot where each point has the value of the radial component in the interval [-45,45].
You will notice that I have attempted to create a mask to retain areas where z<-25 or z>25 (if you want to see the full plot, just change "masked_z = z*mask" with "masked_z = z"). It sort of works, but the mask gets the values 0 in the forbidden areas and therefore it paints it green. What if -say- I want it filled in gray? I have tried to play with the number of levels, with setting the 0 values to something else like 999 and rebuild the levels, but I never reached the desired result, which also include having the colorbar exactly as it is now. Does anybody have a solution to propose?
Thanks!
PRO test_th
COMPILE_OPT idl2
;CREATE "TARGET" PLOT
theta=5*FINDGEN(72)*!DTOR
r=FINDGEN(91)
nr=N_ELEMENTS(r)
nt=N_ELEMENTS(theta)
z = MAKE_ARRAY(nt,nr)
FOR m=0,nt-1 do z[m,*] = r-45
; CREATE LEVELS
nlevels=9
step = 2*MAX(z) / nlevels
levels = MIN(z) + INDGEN(nlevels+1)*step
; CREATE MASKED DATA
mask = MAKE_ARRAY(nt,nr,value=0)
index=WHERE(ABS(z) gt 25)
IF index[0] NE -1 THEN mask[index]=1
masked_z = z*mask
; PLOT
cgLoadCT,33, NColors=nlevels, Bottom=0, /Silent
CGDISPLAY
POLAR_CONTOUR, masked_z, theta, r, /Cell_Fill, C_Color=cgColor(String(Indgen(nlevels))), Levels=levels, $
Position=cgAspect(1.0), XStyle=4, YStyle=4, /NoErase
CGColorBar, Divisions=9, /fit, Range=[MIN(z),MAX(z)], XMinor=0, NColors=nlevels, Bottom=0
END
|
|
|