Re: print out a color table

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 26 2012 - 15:12:28 MDT

When you set res@gsnSpreadColors to True, this internally causes the "cnFillColors" resource to be set to an array of color map index values.

You can retrieve this array to get the color index values.

To retrieve this array, use a "getvalues" block. For example:

  plot = gsn_csm_contour_map(wks,data,res)
  getvalues plot@contour
     "cnFillColors" : color_indexes
  end getvalues

You can now use "color_indexes" to subscript the array returned by gsn_retrieve_colormap:

  cmap = gsn_retrieve_colormap(wks)
  cmap_sub = cmap(color_indexes,:)

Note that what's returned doesn't include the background and foreground colors. It only returns the colors used in the color bar.

I've attached an example script.

--Mary

On Mar 26, 2012, at 3:04 PM, anning cheng wrote:

> HI, Mary:
>
> gsn_retrieve_colormap gets all the 202 colors, but i need the RGB value only for the 16 colors. In other words, in need the RGB values after colorspread.
> Thanks,
>
> Anning
> From: Mary Haley <haley@ucar.edu>
> To: anning cheng <anningc@yahoo.com>
> Cc: "ncl-talk@ucar.edu" <ncl-talk@ucar.edu>
> Sent: Monday, March 26, 2012 4:52 PM
> Subject: Re: print out a color table
>
> Use gsn_retrieve_colormap:
>
> http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_retrieve_colormap.shtml
>
>
> On Mar 26, 2012, at 2:07 PM, anning cheng wrote:
>
> > Hi, there
> >
> > I need to print out a color table of 16 colors produced by colorspread from "BlAqGrYeOrRevi200", so the same plot can be reproduced in GrADS. How to get it done?
> >
> >
> > Anning
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>

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

Received on Mon Mar 26 15:12:37 2012

This archive was generated by hypermail 2.1.8 : Tue Mar 27 2012 - 08:50:24 MDT