[ncl-talk] Scatter plot
Mary Haley
haley at ucar.edu
Wed Nov 12 08:05:06 MST 2014
If you simply want to create a map plot with scattered dots or some other
kind of markers on it, then you should use gsn_csm_map to create the map,
and gsn_add_polymarker to add the dots to the map.
We have a few examples of this at:
http://www.ncl.ucar.edu/Applications/polyg.shtml
See examples polyg_8.ncl, polyg_14.ncl, polyg_15.ncl.
If this is not what you want, then please be very specific about what you
mean by a "scatter lat lon" plot.
--Mary
On Fri, Nov 7, 2014 at 9:39 AM, Kunal Bali <kunal.bali9 at gmail.com> wrote:
> Dear Mary
>
> Thanks for your reply but as you mentioned gsn_csm_xy for a scatter plot ,
> its not what i am looking for. I am trying to create scatter lat lon map
> that why i used gsn_csm_contour_map
>
>
>
> ;*************************************************
> ; corel_3.ncl
> ;
> ; Concepts illustrated:
> ; - Calculating a two-dimensional correlation in time
> ; - Reordering an array
> ; - Copying attributes from one variable to another
> ; - Copying coordinate arrays from one variable to another
> ;
> ;************************************************
> 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"
> begin
> ;************************************************
> ; open file and read in variable
> ;***********************************************
> in1 = addfile("/home/kunal/Pictures/NCL_Scripts/plot/AOD_04-11.nc","r")
> in2 = addfile("/home/kunal/Pictures/NCL_Scripts/plot/CO_4-11.nc","r")
>
> tmp1 = in1->Optical_Depth_Land_And_Ocean_Mean_Mean
> tmp2 = in2->CO_total_column_A
>
> lon at units = "degrees_east"
> lat at units = "degrees_north"
>
>
> ;************************************************
>
> ;***********************************************
> var1 = tmp1(lat|:,lon|:)
> var2 = tmp2(lat|:,lon|:)
> ;************************************************
> ; calculate cross correlations
> ;************************************************
> maxlag = 2 ; set lag
>
>
> ccr = esccr(var1,var2,maxlag) ; calc cross correlations
>
> ; copy meta data and coordinate variables using contributed functions
> copy_VarAtts(var1, ccr)
> copy_VarCoords_1(var2,ccr)
>
> ;************************************************
> ; plot the correlations
> ;************************************************
> wks = gsn_open_wks("ps","corel") ; open a ps plot
> gsn_define_colormap(wks,"BlWhRe") ; choose colormap
>
> res = True ; make plot mods
>
> res at cnFillOn = True ; turn on color
>
>
> res at gsnSpreadColors = True ; use full colormap
>
>
> res at lbLabelAutoStride = True ; automatic lb label
> stride
>
> res at cnLinesOn = False ; turn off contour lines
> res at cnLevelSelectionMode = "ManualLevels" ; manually set cn levels
> res at cnMinLevelValF = -1. ; min level
> res at cnMaxLevelValF = 1. ; max level
> res at cnLevelSpacingF = .1 ; contour level spacing
>
> lag = 0
> res at tiMainString = "Correlations at lag "
> plot = gsn_csm_contour_map_ce(wks,ccr,res)
> ;************************************************
> end
>
>
>
>
> Kunal Bali
> Research Scholar
> Radio & Atmospheric Science Division
> CSIR - National Physical Laboratory
> New Delhi - 110012
>
>
>
>
>
>
> On Fri, Nov 7, 2014 at 8:35 PM, Mary Haley <haley at ucar.edu> wrote:
>
>> Kunal,
>>
>> The error message is telling you exactly what the problem is: you are
>> trying to subscript an array as if it were a 3D array, when it is really a
>> 2D array:
>>
>> fatal:Number of subscripts do not match number of dimensions of
>> variable,(3) Subscripts used, (2) Subscripts expected
>> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 63 in
>> file scatter.ncl
>>
>> You are subscripting "ccr" with (:,:,lag), but it is only 2D, so you need
>> (:,lag)
>>
>> You said you are trying to create a scatter graph, but you are calling
>> gsn_csm_contour_map, which is trying to put contours over a map. This won't
>> work because this is not lat/lon data.
>>
>> Do you mean to call gsn_csm_xy for a scatter plot? If so, see example
>> xy_4.ncl at:
>>
>> http://www.ncl.ucar.edu/Applications/xy.shtml#ex4
>>
>> or the scatter plot page:
>>
>> http://www.ncl.ucar.edu/Applications/scatter.shtml
>>
>> --Mary
>>
>>
>> On Fri, Nov 7, 2014 at 3:20 AM, Kunal Bali <kunal.bali9 at gmail.com> wrote:
>>
>>> Dear NCL users
>>>
>>> I have been trying to plor scatter graph but getting an error
>>>
>>> fatal:Number of subscripts do not match number of dimensions of
>>> variable,(3) Subscripts used, (2) Subscripts expected
>>> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 63 in
>>> file scatter.ncl
>>>
>>> please see the attached script
>>>
>>> Thank You
>>>
>>>
>>> Kunal Bali
>>> Research Scholar
>>> Radio & Atmospheric Science Division
>>> CSIR - National Physical Laboratory
>>> New Delhi - 110012
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20141112/7fa0b9fd/attachment.html
More information about the ncl-talk
mailing list