Re: a question about color for overlapped plot

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 20 Jan 2006 08:02:06 -0700 (MST)

NCL color maps can be a bit confusing for this sort of thing.

The "BlueRed" color table has 254 colors: [0 ==> 253]

  gsn_define_colormap(wks,"BlueRed") ; 254
  newcolor = NhlNewColor(wks,0.,1.0,0.) ; add green , now 255 colors
     
Often, when doing contouring, people want the entire colormap
to be used. Thus, they set the folowing resource

  res@gsnSpreadColors = True ; use full colormap
  
If no further resources are set then the entire colormao
Blue=>Red+Green will be used. I speculate, this is what
happened to your plot.

Other resources can be used to modif this behavior. Specifically,
 
  res@gsnSpreadColorStart = 2 ; This is default
  res@gsnSpreadColorEnd = -1 ; This is default
  
The "2" default is obvious. The "-1" mean the last color.
For the "BlueRed" the means [254-1=253] so the colors
used for contouring are 2-253. When you add green
the span would be [2-254] (255-1=254).

To use only the blue-red portion of the color table
for contouring set

  res@gsnSpreadColorEnd = -2 ; 255-2 => 253
  
Then the contouring will use colors 2-253.

The stremlines can still be "green" because you
are specifying a colr in the color table associated
with the work station.

Long answer .... sorry.

D
   
 

> Thanks for the tips. I tried (1) and it did change the color of
>steamlines. However, at the same time it also changes the contour plot.
>Originally I tried to use blue & red to fill contours and green to do
>streamlines--so contour patches and streamlines can vividly seperate from
>each other. Now if I add green as a new color to colormap, green will be
>used to fill contour patches as well. Any ideas how I can fix this?

>Thanks.
>
> Xianglei
>
>On Thu, 19 Jan 2006, Adam Phillips wrote:
>
>> Hi Xianglei,
>>
>> When you set your colormap to the BlueRed colormap, and then ask NCL to grab
>> the color green, NCL will try to get the color in your colormap closest to
>> green. In your case that would be black. There are two possible solutions to
>> this:
>> 1) Use the function NhlNewColor to add the color green to your colormap.
>> gsn_define_colormap(wks,"BlueRed")
>> newcolor = NhlNewColor(wks,0.,1.0,0.)
>>
>> http://www.ncl.ucar.edu/Document/Functions/Built-in/NhlNewColor.shtml
>>
>> 2) Merge another colormap that has green in it with the BlueRed colormap
>> using gsn_merge_colormaps:
>>
>>
http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_merge_colormaps.shtml
>>
>> Specifically, refer to the first example. Instead of specifiying gray colors
>> specify a green color or two. Remember that NCL has a 256 color limit, so in
>> your case you can only add 2 colors to your colormap..
>>
>> Good luck,
>> Adam
>>
>> Xianglei Huang wrote:
>>> Hi All,
>>>
>>> I am trying to use gsn_csm_streamline_contour_map_ce to creat a color
>>> contour plot overlapped with a streamline vector plot. I found that, after
>>> I choose colormap for contour plot, I cannot set the color of the
>>> streamlines as I want. For example, if I set
>>> gsn_define_colormap(wks,"BlueRed")
>>>
>>> And then if I try to plot streamlines in green by
>>> res@stLineColor = "green1"
>>>
>>> It will only plot out the streamlines in black. I tried other named
>>> color as well, the only color working as named is "white". All others
>>> cannot be plotted as named.
>>>
>>> Anyone know how I can go around this? Your help will be highly
>>> appreciated. Thanks.
>>>
>>> Xianglei
>>>
>>> -------------------------------------------------
>>> Xianglei Huang
>>> Princeton AOS Postdoctoral Research Associate
>>> NOAA Geophysical Fluid Dynamics Laboratory
>>> Princeton University Forrestal Campus
>>> 201 Forrestal Road
>>> Princeton, NJ 08540
>>>
>>> xianglei.huang_at_noaa.gov, xianglei_at_princeton.edu
>>> 609-452-6500 extension 6951 (office)
>>> 609-987-5063 (fax)
>>> http://www.princeton.edu/~xianglei
>>> -------------------------------------------------
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk_at_ucar.edu
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> --
>> --------------------------------------------------------------
>> Adam Phillips asphilli_at_ucar.edu
>> National Center for Atmospheric Research tel: (303) 497-1726
>> ESSL/CGD/CAS fax: (303) 497-1333
>> P.O. Box 3000 Boulder, CO 80307-3000
>> http://www.cgd.ucar.edu/cas/asphilli
>>
>_______________________________________________
>ncl-talk mailing list
>ncl-talk_at_ucar.edu
>http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 20 2006 - 08:02:06 MST

This archive was generated by hypermail 2.2.0 : Fri Jan 20 2006 - 08:44:46 MST