Re: can't set explicit colours

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 27 2013 - 13:44:20 MDT

Hi Katja,

I understand now what the issue is. The "GetFillColor" routine doesn't span the full color map, and hence if you give it a large color map but only a small number of contour levels, you won't get a nice span of colors because it will only use the first part of the color map.

I've created a new function called "get_color_index", which takes similar arguments as "GetFillColor, and takes into account the full size of the color map.

To use it, you need to load the attached "span_indexes.ncl" script after your other load commands:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "./span_indexes.ncl"

      pres@gsLineColor=get_color_index(cnLevels,"BlWhRe",avg((/t(j),t(j+1)/)))

Note that I'm using the color map name and not the "cmap" array. This is mainly for convenience so you don't have to retrieve the color map.

You can use a color map array, but you have to give it only the part of the color map you want to span, because it doesn't know if you are giving it a color map with the foreground/background colors included:

      pres@gsLineColor=get_color_index(cnLevels,cmap(2:,:),avg((/t(j),t(j+1)/))) + 2 ; the "+2" is because the index values returned start at 0

In version 6.1.0 and later of NCL, you can now use RGB colors directly without having to first define a color map (in V6.1.0 and later), so I also created a similar function that returns an RGB[A] value. If you use RGBA values, you don't have to predefine the colormap:

; gsn_define_colormap(wks,"BlWhRe")
; cmap = gsn_retrieve_colormap (wks)

      pres@gsLineColor=get_color_rgb(cnLevels,"BlWhRe",avg((/t(j),t(j+1)/)))

--Mary

>
> Zitat von Mary Haley <haley@ucar.edu>:
>
>>
>> On Jun 25, 2013, at 7:33 AM, Katja Lohmüller wrote:
>>
>>> Hi Mary,
>>>
>>> sorry if I didn't explain my problem very well. The trajectory I want to plot is believed to represent the temperature which a plane took along its way from start till destination airport. So I just want to draw one trajectory which represents the temperature in different color levels (e.g. -5°C to -10°C dark blue, -10°C to-15°C light blue etc) in my graphic and not different trajectries in one graphic like it was presented in the example to which you refered to.
>>> Right now, my trajecory is colored dependend on the temperature levels I chose (in my code it's "cnLevels") in some shades of blue from the colormap "BlWhRe" but you can't distinguish the different colors exactly. So right now I am not able to read off the temperature out of my graphic. My idea was to take an explicit color out of my colormap "BlWhRe" and refer it to a level of tempereature. But I was not able to realise this idea with the resources I found in the examples on the NCL website. So my question is now if there is a possibility to realise my idea or if you have an idea how I could solve my problem.
>>>
>>> Thank you for your help!
>>> Katja
>>>
>>
>> Hi Katja,
>>
>> My suggestion is to not use colors out of "BlWhRe", but rather use named colors. You mentioned "dark blue" and "light blue", which are actual named colors in NCL (without the space).
>>
>> Whenever you draw a polyline using NCL, a single polyline can only have one color. There's no way to draw one polyline and have it be different colors.
>>
>> See the attached example.
>>
>> --Mary
>>
>
>
>
> --
> Katja Lohmüller
> Institut fuer Meteorologie und Klimatologie
> Leibniz Universitaet Hannover
> Herrenhaeuser Str. 2
> 30419 Hannover
>
> Email: lohmueller@muk.uni-hannover.de
> Mobil: 0049 176 61396963
> Buero: 0049 511 762 2396
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Thu Jun 27 13:44:33 2013

This archive was generated by hypermail 2.1.8 : Mon Jul 01 2013 - 12:35:42 MDT