[ncl-talk] X-Y correlation plot of 2D Arrays
Tabish Ansari
tabishumaransari at gmail.com
Wed Aug 13 14:17:36 MDT 2014
Hi
I have 2 matrices of say 100x100 elements. I wish to find the correlation
between the corresponding elements of each matrix. I understand that there
will be total 10,000 datapoints to be plotted. (like a(i,j) vs b(i,j))
I am trying to first convert both the 2d arrays to 1d arrays and then use
the function gsn_csm_xy
However, I am not getting the desired plot. Please help me with this.
Pasted below is the draft script I am trying:
; ***********************************************
; correlation.ncl
;
; Concepts illustrated:
; - Drawing a black-and-white XY plot
;
;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; read in data
;************************************************
a = addfile ("../wrfout_d01.nc","r")
b = addfile ("../wrfchemi.nc","r")
x = a->co(0,0,:,:)
y = b->E_CO(0,0,:,:)
x1 = ndtooned(x)
y1 = ndtooned(y)
;************************************************
; plotting parameters
;************************************************
wks = gsn_open_wks ("x11","correlation") ; open
workstation
res = True ; plot mods desired
res at tiMainString = "Basic XY plot" ; add title
plot = gsn_csm_xy (wks,x1,y1,res) ; create plot
end
--
Thanks & Regards
Tabish Umar Ansari
MS Research Scholar
Environmental & Water Resources Engineering Division
Department of Civil Engineering
IIT Madras
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140814/44355621/attachment.html
More information about the ncl-talk
mailing list