[ncl-talk] panel plot with 2 color bars for each plot ( and common color bars)

Adam Phillips asphilli at ucar.edu
Fri Nov 6 09:56:28 MST 2015


Hi Ioana,
One thing that I see is that I think you meant to say res at lbLabelBar*On*,
and not res at lbLabelBar. (Same for tres at lbLabelBar.) I also see that you are
setting dres at cnLevelSelectionMode  = "ManualLevels" but you are not setting
the cnMinLevelValF/cnMaxLevelValF/cnLevelSpacingF resources as you are for
the tres resource list. I believe this will result in NCL choosing the
contour levels for your plots created with the dres resource list, and thus
they are likely not the same for every plot.

I think the solution is to not draw the individual labelbars (by setting
 res at lbLabelBarOn = False), draw the first labelbar by leabing
resP at gsnPanelLabelBar = True, and then drawing the 2nd labelbar manually by
calling gsn_labelbar_ndc. (Alternatively you can call gsn_create_labelbar,
but in this case I think it would be easier to use gsn_labelbar_ndc.)

For various label bar examples, see:
http://www.ncl.ucar.edu/Applications/labelbar.shtml

In the coding below I will assume that your dres resource list will have
the contours defined like this:
dres at cnMinLevelValF       = -0.03                ; set min contour level
dres at cnMaxLevelValF       =  0.03               ; set max contour level
dres at cnLevelSpacingF      =  0.005

I think all you need to do is to add the call to gsn_labelbar_ndc at the
end of your script:
resP at gsnFrame = False   ; do not advance the frame with the gsn_panel call
gsn_panel(wks,plot,(/6,2/),resP)
lbres                      = True
lbres at lbPerimOn            = False               ; no label bar box
lbres at lbOrientation        = "Vertical"        ; orientation
lbres at vpWidthF             = 0.06                 ; size
lbres at vpHeightF            = 0.6
lbres at lbLabelFontHeightF   =  resP at lbLabelFontHeight
lbres at lbLabelAlignment     = "InteriorEdges"     ; where to label
lbres at lbMonoFillPattern    = True                ; fill sold
lbres at lbFillColors         = cmap_r
gsn_labelbar_ndc (wks,14,fspan(-.03,.03,13),0.85,0.5,lbres)
frame(wks)
kk=kk+2
  ll=ll+2
  end do
  end

The only possible issue I see with the above is that I set:
lbres at lbFillColors         = cmap_r

I am not sure if you are setting the exact number of colors that NCL is
using for the plots, or if NCL is spanning cmap_r. If it is the latter
case, I would set dres at cnFillColors manually:
dres at cnFillColors = cmap_r(0::3,:)     ; 0::3 is a guess to span the
colormap
and then you can set
lbres at lbFillColors         = dres at cnFillColors

Hope that at least gets you on the right track. If you have any further
questions please respond to the ncl-talk email list.
Adam









On Fri, Nov 6, 2015 at 6:53 AM, Ioana Colfescu <ioana.colfescu at ed.ac.uk>
wrote:

> Hi,
> I'm trying to do a panel plot in which I want to use 2 different color
> bars in each plot in the panel.
> I do get the plots but I have a problem with the color bars: I'd like to
> deactivate the individual color bars ( for each plot) and have the color
> bars as panel plot color bars - i.e one horizontal ( like in the plot ) and
> one vertical ( the second one which doesn't show up) but what I get is the
> result attached.
>
> Could someone please tell me what should I change in my script to make:
> - the individual color bars disappear for each plot
> -  the second panel plot color bar appear to the left ( the vertical bar)
> I tried to set both the individual or panel resources for plotting the bar
> to False/True but doesn't work.
> I attached the plot and the code. Thanks.
> Ioana
>
> Relevant code part:
>
>
>   plot = new(12,graphic)
>   res                       = True
>   res at gsnDraw               = False    ; turn off draw
>   res at gsnFrame              = False    ; turn off frame
>  ............................
> *  res at lbLabelBar    = False*
>   tres                       = res
>   dres                       = res
>   tres at cnFillPalette         = "BlWhRe"
>  * tres at lbLabelBar    = False*
>   tres at lbOrientation         = "horizontal"
>   tres at mpFillOn              = False               ; turn off map fill
>   tres at cnLevelSelectionMode  = "ManualLevels"
>   tres at cnMinLevelValF       = -0.03                ; set min contour level
>   tres at cnMaxLevelValF       =  0.03               ; set max contour level
>   tres at cnLevelSpacingF      =  0.005
>  * cmap_r              = read_colormap_file("NCV_manga")*
> *  dres at cnFillPalette  = cmap_r*
>   *d**res at lbLabelBar    = False*
>   dres at cnLevelSelectionMode  = "ManualLevels"
>   dres at mpShapeMode  = "FreeAspect"
>   kk=0
>   ll=1
>   do ii=0,5
>   plot(kk) = gsn_csm_contour_map(wks,cont1(ii,:,:),tres)
>   newvar=new((/dimsizes(cont1)/),typeof(cont1))
>   newvar(ii,:,:)=agcms1 at _FillValue
>   newvar(ii,{-25:25},:)=cont1(ii,{-25:25},:)
>   ter_plot = gsn_csm_contour(wks,newvar(ii,:,:)*100,dres)
>   overlay(plot(kk),ter_plot)
>   plot(ll) = gsn_csm_contour_map(wks,aagcm1(ii,:,:),tres)
>   newvar2=new((/dimsizes(aagcm1)/),typeof(aagcm1))
>   newvar2(ii,:,:)=aagcm1 at _FillValue
>   newvar2(ii,{-25:25},:)=aagcm1(ii,{-25:25},:)
>   ter_plot2 = gsn_csm_contour(wks,newvar2(ii,:,:)*100,dres)
>   overlay(plot(ll),ter_plot2)
>   resP=True
>   resP at gsnMaximize         = True         ; large format
> *  resP at gsnPanelLabelBar    = True *        ; add common colorbar
>   resP at lbLabelAutoStride   = True         ; auto stride on labels
>   resP at lbLabelFontHeight  = 0.015
>   resP at lbOrientation =   "horizontal"
> ;  draw(plot)
> ;  frame(wks)
>   gsn_panel(wks,plot,(/6,2/),resP)
>   kk=kk+2
>   ll=ll+2
>   end do
>   end
>
>
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151106/da66403b/attachment.html 


More information about the ncl-talk mailing list