[ncl-talk] Can't figure out how to increase thickness of the lines in the legend

Ruksana Abedin ruksana.abedin at gmail.com
Fri Jan 22 09:32:34 MST 2016


Hi,

I need to increase the thickness of the lines used as the indicators of the
data types (RCM, UoD, GPCC, etc.) within the legend. Otherwise, reader can
not see properly the legend and finds it hard to identify the line's colour
indicating for a specific data source.

Any suggestions will be highly appreciated.

Thank you,
Ruksana


;*****************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
;*****************************************************
begin
;*****************************************************
;read in data
;*****************************************************
f0=addfile ("....../wah2_sas_1985_2007.part.LRBdesh.ymonmean_1_11.nc",
"r");
f = addfile("......./APHRO_LRBdesh_ppt_1985_2007_ymonmean_1_11.nc", "r")
f1 = addfile("......./GPCC.precip.ymonmean_1_11.1985-2007.v6.360d.LRBdesh.nc
","r")
f2 = addfile("......../UoD.precip.360d.ymonmean.1985_2007_LRBDesh.v301.nc
","r")

;*****************************************************
; parameters
;*****************************************************

PPT_mod = f0->field90(:,0,:,:)
PPT_mod = PPT_mod*86400

PPT_obs = f->precip
PPT_obs1 = f1->precip/30
PPT_obs2 = f2->precip/3

fldmean0 = wgt_areaave_Wrap(PPT_mod,1.0,1.0,1)
fldmean = wgt_areaave_Wrap(PPT_obs,1.0,1.0,1)
fldmean1 = wgt_areaave_Wrap(PPT_obs1,1.0,1.0,1)
fldmean2 = wgt_areaave_Wrap(PPT_obs2,1.0,1.0,1)

time = f0->time0
x = PPT_mod&time0
timax = dimsizes(time)-1

;--convert the time proleptic_gregorian calendar to UTC date
utc_date   = cd_calendar(time,0)

;-- set date variable names

year     = tointeger(utc_date(:,0))
month     = tointeger(utc_date(:,1))
day     = tointeger(utc_date(:,2))
hour      = tointeger(utc_date(:,3))
minute      = tointeger(utc_date(:,4))
second      = utc_date(:,5)

;-- write date as string (MM)
date_str_i = sprinti("%0.2i",month)

;-- create the time strings, plot every axis annotation
incr     = 1
labels      = (/date_str_i(0::incr)/)
labels   = (/"J","F","M","A","M","J","J","A","S","O","N"/)

;-- set resources
res = True
res at trXMinF           = time(0)             ; time minimum on axis
res at trXMaxF           = time(timax)         ; time maximum on axis
res at tmXBMode         = "Explicit"           ; explicit time setting
res at tmXBValues         = PPT_mod&time0(::incr)  ; axis tick position
res at tmXBLabels         = labels


colors = (/"blue","sky blue","yellow","orange"/)
lg_labels = (/"RCM","APHRODITE","GPCC","UoD"/)

printVarSummary(time)
printVarSummary(PPT_mod)
printVarSummary(PPT_obs)
printVarSummary(PPT_obs1)


wks = gsn_open_wks("eps","annpptcycle")

res =True
res at gsnDraw    = False
res at gsnFrame   = False
res at gsnPaperOrientation = "portrait"

res= True   ; plot mods desired
res =True
res at gsnMaximize= True
res at gsnDraw    = False
res at gsnFrame   = False
res at gsnPaperOrientation = "portrait"


res= True   ; plot mods desired
res at tiMainString = "Bangladesh with Larger Region"
res at tiYAxisString   = "Precipitation (mm/day)"
res at tiXAxisString   = "months"
res at xyLineThicknessF = (/6,5,5,5/)
res at trYMinF     = 0.0
res at trYMaxF     = 15.0

res at xyLineColor          = colors(0)
plot0 = gsn_csm_xy(wks,x,fldmean0,res)

res at xyLineColor          = colors(1)
plot1 = gsn_csm_xy(wks,x,fldmean,res)

res at xyLineColor          = colors(2)
plot2 = gsn_csm_xy(wks,x,fldmean1,res)

res at xyLineColor          = colors(3)
plot3 = gsn_csm_xy(wks,x,fldmean2,res)

overlay(plot0,plot1)
overlay(plot0,plot2)
overlay(plot0,plot3)


; Attach a legend

lgres = True
lgres at lgLineColors              = colors
lgres at lgMonoItemType        = True
lgres at lgItemType        = "Lines"
lgres at lgMonoDashIndex        = True
lgres at lgDashIndex        = "SolidLine"
lgres at gsLineDashPattern         = 0.
lgres at gsLineThicknessF          = 5.
lgres at lgLabelFontHeightF     = 0.25
lgres at lgBoxMinorExtentF      = 0.25
lgres at vpWidthF            = 0.25
lgres at vpHeightF         = 0.25
lgres at pmLegendDisplayMode     = "Always"
lgres at pmLegendWidthF          = 0.6
lgres at pmLegendHeightF          = 0.1
lgres at xyExplicitLabels         = lg_labels
lgres at lgBoxMinorExtentF     = 0.8
lgres at lgPerimOn                 = False
legend = gsn_create_legend(wks, 4, lg_labels, lgres)

amres                 = True
amres at amJust             = "BottomRight"     ; Use bottom right corner of
box for determining its location.
amres at amOrthogonalPosF        = -0.12
amres at amParallelPosF         = -0.1

annoid  =  gsn_add_annotation(plot0, legend, amres)  ; add legend to plot

draw(plot0)

frame(wks)

end


[image: Inline image 1]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160122/a1e0a3ae/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.jpeg
Type: image/jpeg
Size: 430640 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160122/a1e0a3ae/attachment-0001.jpeg 


More information about the ncl-talk mailing list