[ncl-talk] Help: Errors when trying to specify xyMarkers, Marker Colors, and Marker Labels using gsn_csm_xy

Rashed Mahmood rashidcomsis at gmail.com
Thu May 31 12:26:58 MDT 2018


replace:
from res2 = "True"
to    res2 = True

By placing True in double quotes makes res2 a string rather than a logical
expression.

On Thu, May 31, 2018 at 11:13 AM, Tyler Herrington <therring at uwaterloo.ca>
wrote:

> Good afternoon,
>
> I am attempting to create a scatterplot in which each data point has a
> specified color and marker style:
>
> ; These files are loaded by default in NCL V6.2.0 and newer
> 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"
>
>
> begin
>
> ;*********************
> ; Create model array
> ;*********************
>
> mdl = new((/28,1/),"string")
> mdl(0,0) = "ACCESS1-0"
> mdl(1,0) = "ACCESS1-3"
> mdl(2,0) = "bcc-csm1-1"
> mdl(3,0) = "bcc-csm1-1-m"
> mdl(4,0) = "BNU-ESM"
> mdl(5,0) = "CanESM2"
> mdl(6,0) = "CCSM4"
> mdl(7,0) = "CNRM-CM5"
> mdl(8,0) = "CSIRO-Mk3-6-0"
> mdl(9,0) = "FGOALS-g2"
> mdl(10,0) = "FGOALS-s2"
> mdl(11,0) = "GFDL-CM3"
> mdl(12,0) = "GFDL-ESM2G"
> mdl(13,0) = "GFDL-ESM2M"
> mdl(14,0) = "GISS-E2-H"
> mdl(15,0) = "GISS-E2-R"
> mdl(16,0) = "HadGEM2-ES"
> mdl(17,0) = "inmcm4"
> mdl(18,0) = "IPSL-CM5A-LR"
> mdl(19,0) = "IPSL-CM5A-MR"
> mdl(20,0) = "IPSL-CM5B-LR"
> mdl(21,0) = "MIROC5"
> mdl(22,0) = "MIROC-ESM"
> mdl(23,0) = "MPI-ESM-LR"
> mdl(24,0) = "MPI-ESM-MR"
> mdl(25,0) = "MPI-ESM-P"
> mdl(26,0) = "MRI-CGM3"
> mdl(27,0) = "NorESM1-M"
>
>
> ;********************************************
> ; Read in Tundra and Boreal Albedo Feedbacks
> ;********************************************
>
> TundirMAM = "/praid/users/herringtont/Caldwell_2016/monthly_data/CLM/by_
> model/alb_fbk_maps/All.Tundra/fldmean/seasmean/MAM/"
>
> BordirMAM = "/praid/users/herringtont/Caldwell_2016/monthly_data/CLM/by_
> model/alb_fbk_maps/NET.Boreal/fldmean/seasmean/MAM/"
>
> TunfilMAM = TundirMAM+"CMIP5_fbks_monres_MAM_AllModels_alb_fbk_maps_All.
> Tundra_seasmean.nc
> <http://cmip5_fbks_monres_mam_allmodels_alb_fbk_maps_all.tundra_seasmean.nc/>
> "
>
> BorfilMAM = BordirMAM+"CMIP5_fbks_monres_MAM_AllModels_alb_fbk_maps_NET.
> Boreal_seasmean.nc
> <http://cmip5_fbks_monres_mam_allmodels_alb_fbk_maps_net.boreal_seasmean.nc/>
> "
>
> TunMAM = addfile(TunfilMAM,"r")
> BorMAM = addfile(BorfilMAM,"r")
>
> TunMAM2 = TunMAM->alb_fbk_maps(:,0,0)
> BorMAM2 = BorMAM->alb_fbk_maps(:,0,0)
>
> ccr = escorc(BorMAM2,TunMAM2) ; calculate correlation coefficient
> ccr2 = decimalPlaces(ccr,3,True)
>
> ;******************************************************
> ; Create MAM Seasonal Mean Albedo Feedback Scatterplot
> ;******************************************************
>
> wks  = gsn_open_wks("png","MAM_Albedo_Feedback_ScatterPlot_corr_labels")
>            ; send graphics to PNG file
>
> res2                     = "True"                   ; plot mods desired
>
> res2 at tmLabelAutoStride = True                     ; nice tick mark labels
> res2 at xyMarkLineMode         = "Markers"
>
> res2 at xyMarkers              = (/0,0,1,1,2,3,4,5,6,7,7,8,8,8,
> 9,9,10,11,12,12,12,13,13,14,14,14,15,16/)
>
> res2 at xyMonoMarkerColor      = "False"         ; Allow different colors
> for markers
>
> res2 at xyMarkerColors         = (/"dodgerblue2","dodgerblue4",
> "firebrick4","tomato3","darkslategrey","forestgreen","chocol
> ate4","plum3","seagreen","cyan2","cyan4","mediumorchid2","mediumorchid4","
> mediumpurple3","orange2","orange4","antiquewhite4","violetre
> d","salmon","salmon2","salmon4","blue","blue4","gold4
> ","goldenrod2","yellow4","magenta4","darkolivegreen4"/)
>
> res2 at xyExplicitLabels       = (/mdl(0,0),mdl(1,0),mdl(2,0),m
> dl(3,0),mdl(4,0),mdl(5,0),mdl(6,0),mdl(7,0),mdl(8,0),mdl(9,
> 0),mdl(10,0),mdl(11,0),mdl(12,0),mdl(13,0),mdl(14,0),mdl(15,
> 0),mdl(16,0),mdl(17,0),mdl(18,0),mdl(19,0),mdl(20,0),mdl(21,
> 0),mdl(22,0),mdl(23,0),mdl(24,0),mdl(25,0),mdl(26,0),mdl(27,0)/)
>
> res2 at xyMarkerSizeF       = 0.005                  ; Marker size (default
> 0.01)
> res2 at tiYAxisString = "Tundra Albedo Feedback (Wm~S~-2~N~K~S~-1~N~)"
> res2 at tiXAxisString = "Boreal Albedo Feedback (Wm~S~-2~N~K~S~-1~N~)"
> res2 at tiMainString = "MAM Mean Albedo Feedbacks"
> res2 at trYMinF             = 0.0
> res2 at trYMaxF             = 4.0
> res2 at trXMinF             = -0.75
> res2 at trXMaxF             = 1.5
>
> res2 at gsnDraw       = False          ; do not draw
> res2 at gsnFrame      = False          ; do not advance
>
> txres                    = True
> txres at txFontHeightF = 0.015                   ; change font height
>
> ;---Set some legend resurces
> res2 at pmLegendDisplayMode    = "Always"         ; Turn on the legend
> res2 at lgOrientation          = "horizontal"     ; Default is vertical
> res2 at pmLegendWidthF         = 0.5             ; Make it wider
> res2 at pmLegendOrthogonalPosF = -0.2             ; Move it up slightly
> res2 at lgPerimOn              = False            ; Turn off the perimeter
> box
>
>
> plot = gsn_csm_xy(wks,BorMAM2,TunMAM2,res2)                  ; create plot
> draw(plot)
> dum = gsn_add_text(wks,plot,"Pearson Correlation: "+ccr2,-0.2,3.8,txres)
> frame(wks)
>
> system("mv *.png /home/herringtont/Caldwell_2016/figures/scatterplot")
>
> end
>
>
>
> Upon running the script, however, I get the following error:
>
> fatal:Argument type mismatch on argument (3) of (gsn_csm_xy) can not coerce
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 107 in
> file Boreal_Tundra_Scatterplot.ncl
>
> Which leads me to suspect that something is wrong with the way that I am
> specifying resources for the plot. Any suggestions on what could be causing
> this?
>
> Thank You,
>
> Sincerely,
>
> Tyler Herrington, MSc
> PhD Student (Climate Science)
> Geography and Environmental Management
> University of Waterloo
>
>
> _______________________________________________
> 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/20180531/1271f954/attachment.html>


More information about the ncl-talk mailing list