[ncl-talk] How to have a plot with different panel label bar

Mary Haley haley at ucar.edu
Tue May 22 16:57:11 MDT 2018


Dear Anahita,

If you have follow-up questions on NCL scripts, it helps to create a new
thread so that the NCL community has a chance to weigh in. Otherwise this
puts the pressure on the person you were working with earlier to
continually answer further questions.

To get different color bars for the A and B panels, you can use
cnFillPalette and assign the desired colormap to each.  To see an example
of this, look at examples panel_26.ncl and panel_29.ncl at:

http://www.ncl.ucar.edu/Applications/panel.shtml#ex26
http://www.ncl.ucar.edu/Applications/panel.shtml#ex29

For further help on using cnFillPalette, go to:

http://www.ncl.ucar.edu/Applications/concepts_list.shtml

and use your browser search to look for "cnFillPalette".

There's no way to individually control the locations of the figure strings,
because the point is that they all show up in the same location on every
plot.

A few things you could do to fix this plot are:

1. Set the X axis maximum for the third plot to a larger value than 0.080,
which would give you more of a margin for the label to be drawn in:

​   r​
es at trXMaxF     =
​0.10​
     ;
​increase
 maximum X-axis value

​2. Draw the three figure strings yourself using gsn_add_text and then you
can control each one individually.

3. Make the label smaller using gsnPanelFigureStringsFontHeightF

4. Make the box containing the label transparent so that you can see the
blue line underneath it, by setting

resP at gsnPanelFigureStringsBackgroundFillColor  = "transparent"

​See example panel_5.ncl for a list of some of these resources and how to
use them.​

http://www.ncl.ucar.edu/Applications/panel.shtml#ex5

I've attached a sample script that shows a case where a figure string
covers the line, and illustrates some of the solutions.  You can get the
atmos.nc data file from:

http://www.ncl.ucar.edu/Applications/Data/

Please look at the other examples on the panel examples page if you
continue to have questions about customizing your panel plots.  There are
many examples and hopefully you can find one that does what you want.

--Mary




On Tue, May 22, 2018 at 2:56 PM, Anahita Amiri Farahani <aamir003 at ucr.edu>
wrote:

> Thanks, it worked, I have to more questions,
>
> How can I put different color bars on the panel a and b, and in panel c
> "c)" covers some part of the plot is there any way to change its position?
>
> On Tue, May 22, 2018 at 1:47 PM, Adam Phillips <asphilli at ucar.edu> wrote:
>
>> You are getting warnings about resources not being applied correctly to
>> your xy plot. Looking at those error messages more closely: are you setting
>> the gsnSpreadColors in your res2 resource list for your xy plot? No, but
>> you are setting that resource in your res resource list. Look at the plot
>> call:
>>  plot(2)  = gsn_csm_xy (wks,Absp3D_summer2,lev3,res)
>> Change the above from res->res2 and you should be good. If not, let
>> ncl-talk know.
>> Adam
>>
>>
>> On Tue, May 22, 2018 at 2:38 PM, Anahita Amiri Farahani <aamir003 at ucr.edu
>> > wrote:
>>
>>> Attached is the correct plot for the last panel, so the title is not
>>> written and also the line color, thickness not matched.
>>> and    res2 at trYReverse = True is not applied. and I got these warnings:
>>>
>>> warning:cnFillOn is not a valid resource in atm_sfc_fine_xy at this time
>>>
>>> warning:gsnSpreadColorStart is not a valid resource in atm_sfc_fine_xy
>>> at this time
>>>
>>> warning:gsnSpreadColors is not a valid resource in atm_sfc_fine_xy at
>>> this time
>>>
>>> warning:lbLabelBarOn is not a valid resource in atm_sfc_fine_xy at this
>>> time
>>>
>>> warning:cnInfoLabelOn is not a valid resource in atm_sfc_fine_xy at this
>>> time
>>>
>>> warning:cnLineLabelsOn is not a valid resource in atm_sfc_fine_xy at
>>> this time
>>>
>>> warning:cnLevelSelectionMode is not a valid resource in atm_sfc_fine_xy
>>> at this time
>>>
>>> warning:cnMinLevelValF is not a valid resource in atm_sfc_fine_xy at
>>> this time
>>>
>>> warning:cnMaxLevelValF is not a valid resource in atm_sfc_fine_xy at
>>> this time
>>>
>>> warning:cnLevelSpacingF is not a valid resource in atm_sfc_fine_xy at
>>> this time
>>>
>>> warning:cnLinesOn is not a valid resource in atm_sfc_fine_xy at this time
>>>
>>>
>>>
>>> Thank you,
>>> Ana
>>>
>>>
>>> On Tue, May 22, 2018 at 1:32 PM, Adam Phillips <asphilli at ucar.edu>
>>> wrote:
>>>
>>>> Hi Anahita,
>>>> Looking at your output and the script I do not see what is wrong. Can
>>>> you respond to ncl-talk with what is wrong with the plot and what error
>>>> messages you are getting?
>>>> Adam
>>>>
>>>> On Tue, May 22, 2018 at 2:20 PM, Anahita Amiri Farahani <
>>>> aamir003 at ucr.edu> wrote:
>>>>
>>>>> Dear Adam,
>>>>>
>>>>> Thanks for your help, I tried to apply what you suggested but got a
>>>>> bunch of warnings and for the last plot did not work, I've attached the
>>>>> code and plot here.
>>>>>
>>>>> On Mon, May 21, 2018 at 3:14 PM, Adam Phillips <asphilli at ucar.edu>
>>>>> wrote:
>>>>>
>>>>>> Hi Anahita,
>>>>>> Change this:
>>>>>> res at lbLabelBarOn        = False           ; turn off individual cb's
>>>>>> to this:
>>>>>> res at lbLabelBarOn        = True          ; turn off individual cb's
>>>>>>
>>>>>> and change this:
>>>>>>  resP at gsnPanelLabelBar = True
>>>>>> to this:
>>>>>>  resP at gsnPanelLabelBar = False
>>>>>>
>>>>>> If you need titles for your labelbars you can use the same resources
>>>>>> in resP but apply them to res. Thus:
>>>>>> res at lbTitleString    = "%"                ; title string
>>>>>> res at lbTitlePosition  = "Right"              ; title position
>>>>>> res at lbTitleFontHeightF= .02                ; make title smaller
>>>>>> res at lbTitleDirection = "Across"             ; title direction
>>>>>>
>>>>>> Hope that helps. If you have any further queries please respond to
>>>>>> ncl-talk.
>>>>>> Adam
>>>>>>
>>>>>> On Fri, May 18, 2018 at 12:33 PM, Anahita Amiri Farahani <
>>>>>> aamir003 at ucr.edu> wrote:
>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> For my plots, I used this scripts to create multiple panels with
>>>>>>> common label bar, this time i have panels those label bars are different,
>>>>>>> how can I add label bar individually under each panel?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> wks = gsn_open_wks("eps","Low_clouds_ann")
>>>>>>> ;gsn_define_colormap(wks,"BlAqGrYeOrRe")
>>>>>>> gsn_define_colormap(wks,"BlWhRe")
>>>>>>>  plot = new(4,graphic)
>>>>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>>>> ;;;;;;;;;;;;
>>>>>>>   res                     = True               ; plot mods desired
>>>>>>>   res at cnFillOn            = True              ; turn on color
>>>>>>>   res at gsnSpreadColors     = True               ; use full color map
>>>>>>>   res at cnLinesOn           = False              ; no contour lines
>>>>>>>   res at cnLineLabelsOn      = False              ; no line labels
>>>>>>>
>>>>>>>
>>>>>>>  ; res at gsnAddCyclic        = False
>>>>>>>   res at gsnDraw             = False           ; don't draw
>>>>>>>   res at gsnFrame            = False           ; don't advance frame
>>>>>>>   res at cnInfoLabelOn       = False           ; turn off cn info label
>>>>>>>   res at cnFillOn            = True            ; turn on color
>>>>>>>   res at gsnSpreadColors     = True            ; spread out color table
>>>>>>>   res at gsnSpreadColorStart = 2               ; color to startt
>>>>>>>
>>>>>>>   res at lbLabelBarOn        = False           ; turn off individual
>>>>>>> cb's
>>>>>>>
>>>>>>> ;  res at cnLevelSelectionMode =  "AutomaticLevels"   ; AutomaticLevels
>>>>>>>
>>>>>>>
>>>>>>>   res at cnLevelSelectionMode =  "ManualLevels"   ; AutomaticLevels
>>>>>>>   res at cnMinLevelValF       = -20.              ; min level
>>>>>>>   res at cnMaxLevelValF       =  20.               ; max level
>>>>>>>   res at cnLevelSpacingF      =  2                ; interval
>>>>>>>
>>>>>>>
>>>>>>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>>>>>> ;;;;;;;;;;;;
>>>>>>>
>>>>>>> res at gsnLeftString       = "CAM4 F_compset"         ; change left
>>>>>>> string
>>>>>>> plot(0) = gsn_csm_contour_map_ce(wks,low_ann_cam4_F,res)
>>>>>>> res at gsnLeftString       = "CAM4 E_compset"         ; change left
>>>>>>> string
>>>>>>> plot(1) = gsn_csm_contour_map_ce(wks,low_ann_cam4_E,res)
>>>>>>> res at gsnLeftString       = "CAM5"         ; change left string
>>>>>>> plot(2) = gsn_csm_contour_map_ce(wks,low_ann_cam5,res)
>>>>>>> res at gsnLeftString       = "GFDL"         ; change left string
>>>>>>> plot(3) = gsn_csm_contour_map_ce(wks,low_ann_gfdl,res)
>>>>>>>
>>>>>>>
>>>>>>> ; ========================= PLOT 2 ==============================
>>>>>>>  res2 = True                            ; res2 probability plots
>>>>>>>
>>>>>>>
>>>>>>>   res2 at gsnDraw              = False           ; Do not draw plot
>>>>>>>   res2 at gsnFrame             = False           ; Do not advance frame
>>>>>>>
>>>>>>>   res2 at cnInfoLabelOn       = False       ; turn off info label
>>>>>>>
>>>>>>>   res2 at cnLinesOn           = False       ; do not draw contour lines
>>>>>>>   res2 at cnLineLabelsOn      = False       ; do not draw contour
>>>>>>> labels
>>>>>>>
>>>>>>>   res2 at cnFillScaleF        = 0.6         ; add extra density
>>>>>>> ;  delete(alpha at long_name)
>>>>>>> ;  delete(alpha at units)
>>>>>>>   res2 at gsnAddCyclic = False
>>>>>>>
>>>>>>> plot2   = gsn_csm_contour(wks,alphat_low_ann_cam4_F, res2)
>>>>>>> plot2   = ShadeGtContour(plot2, 0.05, 17)  ; shade all areas less
>>>>>>> than the
>>>>>>>                                              ; 0.05 contour level
>>>>>>> plot3   = gsn_csm_contour(wks,alphat_low_ann_cam4_E, res2)
>>>>>>> plot3   = ShadeGtContour(plot3, 0.05, 17)
>>>>>>>
>>>>>>> plot4   = gsn_csm_contour(wks,alphat_low_ann_cam5, res2)
>>>>>>> plot4   = ShadeGtContour(plot4, 0.05, 17)
>>>>>>>
>>>>>>> plot5   = gsn_csm_contour(wks,alphat_low_ann_gfdl, res2)
>>>>>>> plot5   = ShadeGtContour(plot5, 0.05, 17)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> overlay (plot(0), plot2)
>>>>>>> overlay (plot(1), plot3)
>>>>>>> overlay (plot(2), plot4)
>>>>>>> overlay (plot(3), plot5)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ;************************************************
>>>>>>> ; create panel
>>>>>>> ;************************************************
>>>>>>>   resP                  = True                    ; modify the panel
>>>>>>> plot
>>>>>>>
>>>>>>>   resP at gsnPanelLabelBar = True                    ; add common
>>>>>>> colorbar
>>>>>>>   resP at gsnPanelFigureStrings = (/"a)","b)","c)","d)"/)      ; add
>>>>>>> strings to panel
>>>>>>> resP at txString         = "Low clolud changes"
>>>>>>> resP at lbTitleString    = "%"                ; title string
>>>>>>> resP at lbTitlePosition  = "Right"              ; title position
>>>>>>> resP at lbTitleFontHeightF= .02                ; make title smaller
>>>>>>> resP at lbTitleDirection = "Across"             ; title direction
>>>>>>> gsn_panel(wks,plot,(/2,2/),resP)
>>>>>>>
>>>>>>>
>>>>>>> delete(plot)
>>>>>>> delete(res)
>>>>>>> delete(resP)
>>>>>>> delete(wks)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thank you,
>>>>>>> Ana
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> 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>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> 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>
>>>>
>>>
>>>
>>
>>
>> --
>> 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>
>>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180522/7a7c35e3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: panel_figures.ncl
Type: application/octet-stream
Size: 1723 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180522/7a7c35e3/attachment.obj>


More information about the ncl-talk mailing list