This function takes as input an array of workstation ids (any dimensionality) and an array of color names (any dimensionality) and returns an array of color map indexes that match the color names the closest.
Note: This function is only available in version 4.1.1 of NCL. If your site is licensed for version 4.1, then you can get version 4.1.1 for free. To get version 4.1.1 of NCAR Graphics software, please contact your site representative. If you don't know who your site representative is, then send email to email@example.com or call (303) 497-1201.
function NhlGetNamedColorIndex( wks : graphic, color_name : string )
begin wks = create "workstation" ncgmWorkstationClass defaultapp "wkColorMap" : (/"white","black","red","green","blue","yellow",\ "cyan","magenta"/) end create i = NhlGetNamedColorIndex(wks,(/"red","yellow","blue","green",\ "cyan","magenta"/)) j = NhlGetNamedColorIndex(wks,(/"gray","brown"/)) print(i) print(j) endthen i will be equal to (/2,5,4,3,6,7/) and j will be equal to (/0,2/). There's no gray or brown defined in the above color map, so when the color map is searched for the closest match to gray and brown, it comes up with white and red, which are color indexes 0 and 2.
NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?