Re: 2 label bars, differents color map

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Nov 04 2011 - 14:31:08 MDT

Hi Vanesa,

One issue with NCL and named colors is that any named color you use must already be in your color map.
Another issue is that you can have at most 256 colors in a color map.

We are planning to get rid of both limitations, and will soon be alpha testing this feature.

Meanwhile, you will need to scale back the WhiteBlue colormap, and then add white, blue, green, etc, to it.

To scale back the WhiteBlue colormap, you can first set it, then retrieve it, then subscript it:

;---Set WhiteBlue colormap
  gsn_define_colormap(wks,"WhiteBlue")

;---Retrieve the RGB triplets
  cmap_rgb = gsn_retrieve_colormap(wks)

;---Grab every other triplet value
  cmap_partial = cmap_rgb(::2,:)

Now, you can merge the named colors with the subscripted WhiteBlue colormap:

; ---Make sure "white" is first and "black" is second, for the background/foreground colors.
  cmap_named = (/"White","Black","Blue","Green","Yellow","Red","Magenta"/)

;---Merge the named colors and the partial WhiteBlue color map
  gsn_merge_colormaps(wks, cmap_named, cmap_partial)

;---This is for debug purposes.
  gsn_draw_colormap(wks)

Now, for your resources, you'll need to make sure that the contour fill for the opts_cf contours
start at the appropriate place in the color map, so you don't get the named colors as
part of it:

  opts@qf@gsnSpreadColorStart = dimsizes(cmap_named)

The default is gsnSpreadColorStart = 2. The above will make sure
it starts after the index of the last named color in your color map.

--Mary

On Nov 4, 2011, at 9:16 AM, Vanesa Bdm wrote:

> Hello, I have 2 labelbars in a plot and I want the first uses the color I set and the other the color of a color map..
> I do this...
>
> gsn_define_colormap(wks,"WhiteBlue") ; Define the colormap
>
>
> LABELBAR1 (the colors I set on cnfillcolors)
>
> ; Plotting options for DBZ
> opts_qg = opts_xy
> opts_qg@cnLevelSelectionMode = "ExplicitLevels"
> opts_qg@cnLevels = (/ 0, 20, 30, 40, 60, 70/)
> opts_qg@cnFillColors = (/"White","Blue","Green", \
> "Yellow","Red","Magenta"/)
> opts_qg@cnMinLevelValF = 0 ; min level
> opts_qg@cnMaxLevelValF = 80 ; max level
> ;opts_qg@pmLabelBarOrthogonalPosF = 0
> opts_qg@cnFillOn = True
> ;opts_qg@gsnContourLineThicknessesScale = 1.0
>
> LABELBAR2 (The colors of the color map WhiteBlue)
>
> ; Plotting options for CF
> opts_cf = opts_xy
> opts_cf@pmLabelBarSide = "right"
> opts_cf@lbOrientation = "vertical"
> opts_cf@pmLabelBarWidthF = 0.2 ; default is shorter
> opts_cf@pmLabelBarHeightF = 0.31 ; default is taller
> opts_cf@cnFillOn = True
>
> But I the color of the color map affect the colors of the LABELBAR1, the LABELBAR2 uses the color of the colormap.
> I try a lot of things that I can remember now.
> What I'm missing!!!
>
> Regards
> _______________________________________________
> 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 Fri Nov 4 14:31:16 2011

This archive was generated by hypermail 2.1.8 : Tue Nov 08 2011 - 15:54:50 MST