comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Shade areas in POLAR_CONTOUR
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Shade areas in POLAR_CONTOUR [message #93575] Wed, 24 August 2016 15:34 Go to next message
Matteo is currently offline  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
Re: Shade areas in POLAR_CONTOUR [message #93653 is a reply to message #93575] Thu, 22 September 2016 14:05 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Wednesday, August 24, 2016 at 5:34:17 PM UTC-5, Matteo wrote:
> 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

I was going to suggest something along the lines of your "set the 0 values to something else like 999". What exactly have you tried along those lines?

-Jeremy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Need help to understand the meaning
Next Topic: TS_HANTS function question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:13:05 PDT 2025

Total time taken to generate the page: 0.00517 seconds