[ncl-talk] Making zero value white in contour plot

Jake Huff jake.huff at stonybrook.edu
Thu Oct 6 08:25:47 MDT 2016


Hello,

Thank you Mary and Dennis for your suggestions I appreciate it.

Jake

On Oct 5, 2016 6:07 PM, "Dennis Shea" <shea at ucar.edu> wrote:

> A 'trick':  If variable 'x' is being plotted:
>
> (a) If 'x' has an _FillValue associated with it
>
>      x = where(x.eq.0, x at _FillValue, x)
>
>
>
> (b) if 'x' does not have a _FillValue, just assign one. EG
>
>     if (.not.isatt(x,"_FillValue")), then
>         x at _FillValue = getVarFillValue(x)
>     end if
>
>   x = where(x.eq.0, x at _FillValue, x)
>
> ====
>   res at cnMissingValFillColor   = "white"    ; maybe "background"
>
>      plot =
>
> On Wed, Oct 5, 2016 at 3:30 PM, Mary Haley <haley at ucar.edu> wrote:
>
>> Jake,
>>
>> In NCL, the colors represent the values *between* contour levels and not
>> exactly equal to a contour level. It's not possible to tell NCL that you
>> want all values equal to 0 to be white, because you need a range of values
>> in order to actually have an area that you can fill in a certain color.
>>
>> Your white value is representing all values >= -5 and < 5.  If you want
>> this to more closely represent values that are equal to zero, then you need
>> to provide a smaller range of values, like -0.1 to 0.1. It will depend on
>> how close your values are to zero.
>>
>> The other possibility is to portray the 0 contour level a different way.
>> For example, if you look at example coneff_1.ncl at:
>>
>> http://www.ncl.ucar.edu/Applications/coneff.shtml#ex1
>>
>> it uses a special resource "gsnContourZeroLineThicknessF" to make the
>> zero contour line double thick.  Of course, in order for this to work, you
>> actually have to have a 0 contour line. For example:
>>
>> res at cnLevelSpacingF  = 5
>>
>> res at cnMinLevelValF = -75
>>
>> res at cnMaxLevelValF = 75
>>
>> You may also want to visit the "symmetric" contours page at:
>>
>> http://www.ncl.ucar.edu/Applications/contoursym.shtml
>>
>> --Mary
>>
>>
>> On Tue, Oct 4, 2016 at 7:57 PM, Jake Huff <jake.huff at stonybrook.edu>
>> wrote:
>>
>>> Hello Everyone,
>>>
>>> I am currently using gsn_csm_contour_map along with cnFillColors to
>>> specify which colors I want on the label bar.
>>>
>>> For example I am specifiying the minimum, maximum and spacing of values
>>> for the contour levels.
>>>
>>> wks = gsn_open_wks("pdf","example")
>>> gsn_define_colormap(wks,"BlWhRe")
>>>
>>> res = True
>>>
>>> res at cnLevelSpacingF  = 10
>>>
>>> res at cnMinLevelValF = -75
>>>
>>> res at cnMaxLevelValF = 75
>>>
>>> res at cnFillColors = (/2,9,13,18,22,28,34,40,0,55,62,70,77,84,90,95,102/)
>>>
>>>
>>> So this makes the contour level from -5 to 5 be white by using value 0
>>> in the cnFillColors. The problem I have is that this is misleading because
>>> it makes a lot of values white instead of just the zero value.
>>>
>>>
>>> My question is how to make a contour plot with a color bar that has the
>>> zero value be white and all other values be non-white.
>>>
>>>
>>> Thanks,
>>>
>>> Jake
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161006/70b0fd86/attachment.html 


More information about the ncl-talk mailing list