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

Home » Public Forums » archive » Contour: difference between IDL 8.0 and IDL 8.4
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Contour: difference between IDL 8.0 and IDL 8.4 [message #94213 is a reply to message #94204] Thu, 23 February 2017 11:39 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Wednesday, February 22, 2017 at 12:57:52 AM UTC-7, burkina wrote:
> On Tuesday, 21 February 2017 17:25:34 UTC+1, Chris Torrence wrote:
>> Hi Stefano,
>>
>> Here's what happened - as soon as we released IDL 8.0, users started complaining that the fill behavior was different than the direct graphics contour procedure. So we changed the default behavior to make it easier for people to transition from direct to function graphics. Unfortunately, that broke backwards compatibility for your case.
>>
>> However, there is a better workaround that avoids having to patch old code (which would break again if you upgrade). You can actually specify a "transparency" value for the c_color values by giving them 4 values ("RGBA" instead of "RGB"). The "A" (or alpha) ranges from 0 (transparent) to 255 (opaque). The documentation doesn't mention this, and I'll fix that for the next version.
>>
>> Here's a sample program where I do the contour plot, get the color values back out, then set the transparency for one contour. To try out this program you'll need to revert to your unmodified 8.4 code.
>>
>> I'm sorry about breaking your code, and I hope this workaround helps.
>> Cheers,
>> Chris
>> IDL Project Lead
>> Harris Geospatial
>>
>> Sample code:
>>
>> h = hanning(30,30)
>> x = findgen(30)
>> c = contour(1-h, x, x, rgb_table=1, /fill, c_value=[0,0.25,0.5,0.75])
>> colors = c.c_color
>> dim = size(colors,/dim)
[color=teal]>> colors = [colors, 255b+bytarr(1,dim[1])] ; change to RGBA[/color]
>> colors[3,3] = 0 ; make transparent
>> c.c_color = colors
>>
>> c1 = contour(1-h, x+10, x+10, rgb_table=2, /fill, $
>> c_value=[0,0.25,0.5,0.75], /overplot)
>> colors = c1.c_color
>> dim = size(colors,/dim)
[color=teal]>> colors = [colors, 255b+bytarr(1,dim[1])] ; change to RGBA[/color]
>> colors[3,3] = 0 ; make transparent
>> c1.c_color = colors
>
> Hi Chris,
>
> thanks!
>
> This is a great solution. However, it obviously overrides any 'transparency' set in the contour command. To preserve it, I have to define it for all the colors, like this:
>
> colors[3,0]=150
> colors[3,1]=150
> colors[3,2]=150
>
> With this other fix, I can actually get exactly the same result I have with IDL8.0.
>
> May I suggest you a more 'elegant' fix for the next releases? You could consider a modification of the 'transparency' parameter: if it's a single number, it could be treated as it is now, as the transparency for all the colors. On the other hand, if it's an array with the same number of elements of c_color, it could represent the alpha values for each color/contour. What do you think?
>
> Thanks again,
>
> Stefano

That's a great idea. I'm not sure if it will make it into the next release, but I'll add it to the list!
-Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Xrange ignored in Errorplot, why?
Next Topic: print data in colunms

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

Current Time: Wed Oct 08 13:53:23 PDT 2025

Total time taken to generate the page: 0.00544 seconds