[ncl-talk] gsn_Spread_Colors issue

Mary Haley haley at ucar.edu
Thu Jul 5 09:06:50 MDT 2018


Hi Rashed,

The differences you are seeing in colorbar_test.ncl is due to the fact that
gsnSpreadColors operates on whatever color map is associated with the
workstation, and since the the workstation color map uses 0 and 1 as the
background and foreground colors, gsnSpreadColors always starts at color
index 2.

When you do this kind of call
​, however:​


    colors   = span_color_rgba(cmap,nlevels+1)

the function ​
will return a span of the
​whole​
color map, including the first two colors (which you defined as white and
black respectively).

You can get gsnSpreadColors to behave the same way as span_color_rgba, by
telling gsnSpreadColors to start at index 0 instead of index 2:

res at gsnSpreadColorStart = 0

You're right though, you should use cnFillPalette in place of
gsnSpreadColors.

Thanks for providing sample scripts that explained your issue.

--Mary



On Wed, Jul 4, 2018 at 12:53 PM, Rashed Mahmood <rashidcomsis at gmail.com>
wrote:

> I just realized that gsn_SpreadColors is deprecated in NCL 6.1 and later.
>
> On Tue, Jul 3, 2018 at 7:49 PM, Rashed Mahmood <rashidcomsis at gmail.com>
> wrote:
>
>> Hi all,
>>
>> It seems that there is a possible issue (may be a previously known one)
>> when using "gsnSpreadColors" resource. There is difference of one color
>> between colorbar of a map plot and manual creation of colorbar with same
>> levels and colors.
>>
>> The attached simple script "colorbar_test.ncl" creates dummy data and
>> runs "as is". The top two lines and the following two can be turned on and
>> off to create attached fig_1 and fig_2, each containing two colorbars one
>> for map (upper one) and one for coloured markers (lower one). For fig_1 the
>> colorbars are same (from 0 to onwards) however in fig_2 the central color
>> is different. The only difference for plotting these is the number of
>> levels (odd or even).
>>
>> As a test, when I used same script using "cnFillPalette", in attached
>> script named "No_problem_script.ncl", the colorbars are exactly same for
>> both contour levels. The "no problem" figures are also attached.
>>
>> I think this is related to how the colours are spanned in two routines
>> "gsnSpreadColors" and "cnFillPalette", but still it is surprising to see
>> the differences in colorbars of fig_1 and fig_2.
>>
>>
>> Any thoughts on this would be appreciated. I should now be using
>> "cnFillPallette", always!
>>
>> Cheers,
>> Rashed
>>
>>
>
>
> _______________________________________________
> 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/20180705/7a712fcd/attachment.html>


More information about the ncl-talk mailing list