Re: Labelbar problem in panel plot

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu Apr 26 2012 - 12:32:58 MDT

Hi Imogen,
I think you need to set the following general resources:
res@cnLevelSelectionMode = "ExplicitLevels"
res@cnFillOn = True
res@gsnSpreadColors = False ; (right now you're setting it to True)

Then set the appropriate cnLevels and cnFillColors within your do loop,
like this:

do n=0,nplots-1
      gsn_define_colormap(wks,colormaps(n))
      if (n.eq.0) then
         res@cnLevels = (/-20,-10,0,10,20/)
         res@cnFillColors = (/2,3,4,5,6,7/)
      end if
      if (n.eq.1) then
         res@cnLevels = (/-2,-1,0,1,2/)
         res@cnFillColors = (/4,5,6,7,10,12/)
      end if
      ; and so on

      plots(n) = gsn_csm_contour_map(wks,data(n,:,:),res) end do
      delete(res@cnLevels)
      delete(res@cnFillColors)
end do

See examples 3, 6, and others on this page:
http://www.ncl.ucar.edu/Applications/color.shtml

Hope that helps.. If not, let ncl-talk know..
Adam

On 04/26/2012 08:47 AM, Imogen Fletcher wrote:
> Hi everyone,
>
> I've created a panel plot consisting of 6 maps, each using a different
> colour table, based on the example panel_26.ncl from
> http://www.ncl.ucar.edu/Applications/panel.shtml . Below is the relevant
> part of the script (the data files are too big to attach here and
> involve a lot of modification at the beginning of the script).
>
> The problem I'm having is that each dataset has a different scale, and I
> want to manually set the levels and the colours for each map, so that
> certain colours fall at certain values (eg white at 0, red for negative
> values etc.) I've attached what I've managed to produce so far, so
> hopefully this question will make sense!
>
> If anyone has any suggestions of a way to achieve this, it would be much
> appreciated!
>
> Thanks,
> Imogen
>
>
> wks = gsn_open_wks("png","dsl_npp_fire_mean_trend")
>
> res = True
> res@gsnDraw = False
> res@gsnFrame = False
>
> res@cnFillMode = "RasterFill"
> res@gsnAddCyclic = True
> res@mpOutlineOn = True
> res@mpPerimOn = False
> res@lbLabelBarOn = True
>
> res@gsnLeftString = ""
> res@gsnRightString = ""
>
> res@cnLinesOn = False
> res@cnFillOn = True
> res@gsnSpreadColors = True
>
> res@cnLevelSelectionMode = "AutomaticLevels"
>
>
> nplots = 6
> plots = new(nplots,graphic)
>
> colormaps =
> (/"WhiteBlue","GreenYellow","WhiteYellowOrangeRed","BlWhRe","BlWhRe","BlWhRe"/)
> do n=0,nplots-1
> gsn_define_colormap(wks,colormaps(n))
> plots(n) = gsn_csm_contour_map(wks,data(n,:,:),res)
> end do
>
> pres = True
> pres@gsnMaximize = False
> pres@gsnFrame = False
> pres@gsnPanelLabelBar = False
> pres@pmLabelBarWidthF = 1
>
> pres@gsnDraw = False
>
> pplots = gsn_panel_return(wks,plots(0),(/1,1/),pres)
>
>
> pres@gsnDraw = True
> pres@gsnPanelLeft = 0.
> pres@gsnPanelRight = 0.45
> pres@gsnPanelTop = 1.
>
>
> pres@gsnPanelFigureStringsPerimOn = False
> pres@gsnPanelFigureStringsFontHeightF = 0.01
> pres@amJust = "TopLeft"
>
> fig_strs = (/"DSL mean","NPP mean","Fire count mean","DSL trend","NPP
> trend","Fire count trend"/)
>
> do n=0,2
> gsn_define_colormap(wks,colormaps(n))
> pres@gsnPanelFigureStrings = fig_strs(n)
> pres@gsnPanelTop = 1-n*0.4
> gsn_panel(wks,plots(n),(/1,1/),pres)
> pres@txString = ""
> end do
>
> pres@gsnPanelLeft = 0.5
> pres@gsnPanelRight = 0.95
> pres@gsnPanelTop = 1.
>
> do n=3,5
>
> gsn_define_colormap(wks,colormaps(n))
> pres@gsnPanelFigureStrings = fig_strs(n)
> pres@gsnPanelTop = 1-(n-3)*0.4
> gsn_panel(wks,plots(n),(/1,1/),pres)
> res@gsnSpreadColors = True
> pres@txString = ""
> end do
>
> frame(wks)
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 26 12:33:06 2012

This archive was generated by hypermail 2.1.8 : Mon Apr 30 2012 - 09:21:12 MDT