[ncl-talk] How to these three plots in one figure?

Adam Phillips asphilli at ucar.edu
Mon May 21 16:27:21 MDT 2018


Hi Anahita,
I am a bit unsure if you are restating your previous question a different
way. The coding as you sent does not match the output plots. It looks to me
like two plots should be paneled, while one plot should not be.  Thus, I'm
not sure how exactly to advise. Something like the following should work:

wks = gsn_open_wks("eps","atm_sfc_fine")
;gsn_define_colormap(wks,"BlAqGrYeOrRe")
;gsn_define_colormap(wks,"BlWhRe")
 plot = new(2,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        = True          ; turn off individual cb's

;  res at cnLevelSelectionMode =  "AutomaticLevels"   ; AutomaticLevels


  res at cnLevelSelectionMode =  "ManualLevels"   ; AutomaticLevels
  res at cnMinLevelValF       = -40.              ; min level
  res at cnMaxLevelValF       =  40.               ; max level
  res at cnLevelSpacingF      =  4               ; interval

plot = new(3,graphic)
res at gsnLeftString       = "Solar radiation absorption in the atmosphere"
     ; change left string
plot(0) = gsn_csm_contour_map_ce(wks,Absp,res)
res at gsnLeftString       = "Surface net flux"         ; change left string
plot(1) = gsn_csm_contour_map_ce(wks,sfc,res)

res2                   = True                       ; plot mods desired
res2 at gsnDraw = False
res2 at gsnFrame = False
;res2 at tiMainString      = "Vertical profile of atmospheric heating rate"
         ; add title
res2 at tiYAxisString = "Surface net flux (W/m^2)"  ; xaxis string
res2 at tiXAxisString = "Latitude";Pressure levels (hPa)"

res2 at trYMinF     = -10;0 ; set minimum Y-axis value
res2 at trYMaxF     = 1;12250;1200 ; set maximum Y-axis value
;res2 at trXMinF     = -0.5      ; set minimum X-axis value
;res2 at trXMaxF     = 1.2      ; set maximum X-axis value
; res2 at trYReverse = True                     ; reverse Y-axis
res2 at xyDashPattern  = 0                         ; Make curves all solid
res2 at xyLineColors      = "blue"          ; change line color
res2 at xyLineThicknesses = 4.0
 plot(2)  = gsn_csm_xy (wks,lat,sfc_summer2,res) ; create plot

;************************************************
; create panel
;************************************************
  resP                  = True                    ; modify the panel plot

  resP at gsnPanelLabelBar = False                  ; add common colorbar
  resP at gsnPanelFigureStrings = (/"a)","b)"/)      ; add strings to panel
gsn_panel(wks,plot,(/1,3/),resP)

Note that you need to set res2 at gsnFrame/gsnDraw to False to use gsn_panel.
There are numerous examples of paneling on the paneling Applications page
here:
http://www.ncl.ucar.edu/Applications/panel.shtml

Again, if you have any further questions please reply to ncl-talk.
Adam


On Fri, May 18, 2018 at 12:41 PM, Anahita Amiri Farahani <aamir003 at ucr.edu>
wrote:

> Hi all,
>
> I have three plots and want to create one plot with three panels how can I
> do that. I've attached the figures here and also the script for them.
>
>
>
>  wks = gsn_open_wks("eps","atm_sfc_fine")
> ;gsn_define_colormap(wks,"BlAqGrYeOrRe")
> ;gsn_define_colormap(wks,"BlWhRe")
>  plot = new(2,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       = -40.              ; min level
>   res at cnMaxLevelValF       =  40.               ; max level
>   res at cnLevelSpacingF      =  4               ; interval
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> res at gsnLeftString       = "Solar radiation absorption in the atmosphere"
>        ; change left string
> plot(0) = gsn_csm_contour_map_ce(wks,Absp,res)
> res at gsnLeftString       = "Surface net flux"         ; change left string
> plot(1) = gsn_csm_contour_map_ce(wks,sfc,res)
>
>
>
>
>
>
> ;************************************************
> ; create panel
> ;************************************************
>   resP                  = True                    ; modify the panel plot
>
>   resP at gsnPanelLabelBar = True                    ; add common colorbar
>   resP at gsnPanelFigureStrings = (/"a)","b)"/)      ; add strings to panel
> ;resP at txString         = "Annual SDE changes at the surface"
> resP at lbTitleString    = "W/m^2"                ; 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,(/1,2/),resP)
>
>
> delete(plot)
> delete(res)
> delete(resP)
> delete(wks)
>
>
>
>
>
>
>
>
>
>
>
> ;************************************************
> ; plotting parameters
> ;************************************************
>  wks   = gsn_open_wks ("eps","sfc_lat_summer")                  ; send
> graphics to PNG file
>
>  res                   = True                       ; plot mods desired
> ;res at tiMainString      = "Vertical profile of atmospheric heating rate"
>            ; add title
> res at tiYAxisString = "Surface net flux (W/m^2)"  ; xaxis string
> res at tiXAxisString = "Latitude";Pressure levels (hPa)"
>
> res at trYMinF     = -10;0 ; set minimum Y-axis value
> res at trYMaxF     = 1;12250;1200 ; set maximum Y-axis value
> ;res at trXMinF     = -0.5      ; set minimum X-axis value
> ;res at trXMaxF     = 1.2      ; set maximum X-axis value
> ; res at trYReverse = True                     ; reverse Y-axis
> res at xyDashPattern  = 0                         ; Make curves all solid
> res at xyLineColors      = "blue"          ; change line color
> res at xyLineThicknesses = 4.0
>  plot  = gsn_csm_xy (wks,lat,sfc_summer2,res) ; create plot
> ;************************************************
> delete(wks)
>
>
>
>
> Thanks,
> 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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180521/46a174cc/attachment-0001.html>


More information about the ncl-talk mailing list