# [ncl-talk] Scatter plot

Mary Haley haley at ucar.edu
Thu Sep 18 16:47:03 MDT 2014

```​There are a couple of problems.

First, you are trying to use "ind" on a 2D array.  "ind" can only be used
on a 1D array.​ That is why you are getting this error:

fatal:Number of dimensions in parameter (0) of (ind) is (2), (1) dimensions
were expected

Second, you can't get indices into a 2D array and then plug them into 1D
arrays that only represent the X or Y dimension of your data, which you
appear to be attempting with:

ii = ind(levels(i).le.data1.and.data1.lt.levels(i+1))

What you need to do is create 2D versions of height and month that are the
same size as data1, with their values propagated across the appropriate
dimensions. You then need to convert these two arrays, and data1 to 1D
arrays, so you can use this with "ind".  This is rather awkward, and I wish
there was a better way:

UNTESTED:

height_2d_as_1d = ndtooned(conform(data1,height,0))
month_2d_as_1d  = ndtooned(conform(data1,month,1))
data1_2d_as_1d  = ndtooned(data1)
do i=0,nlevels-2
ii := ind(levels(i).le.data1_2d_as_1d.and.data1_2d_as_1d.lt.levels(i+1))
mkres at gsMarkerIndex = 16          ; Filled dots
mkres at gsMarkerColor = colors(i)
dum_fill(i) =
end do

--Mary

On Wed, Sep 10, 2014 at 2:15 AM, Ipsita Putatunda <
ipsita.putatunda at gmail.com> wrote:

> Hi all,
>    I have a 2D variable (nlev*ntim) with values ranges approx from 0 to
> 20. I want to make a scatter plot with xaxis labeling ntim and yaxis with
> nlev, and the values am grouping in 10 sets
> (0-2,2-4,4-6,6-8,8-10,10-12...etc) and trying to put it in different
> colors. While doing so am getting problem related to array subscription.
> The way am making the subsets of the values may be wrong.
>
> My script is attached herewith.
> it is giving error
>
> fatal:Number of dimensions in parameter (0) of (ind) is (2), (1)
> dimensions were expected
> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 56 in
> file
>
> At line 56
>   ii = ind(levels(i).le.data1.and.data1.lt.levels(i+1))
> as the data1 is 2D I have to write it some other way for making the subset.
> I have tried to follow the examples
> http://www.ncl.ucar.edu/Applications/Scripts/scatter_6.ncl
> http://www.ncl.ucar.edu/Applications/Scripts/scatter_8.ncl
> but getting similar issue.
> I know where am making mistake,but don't know how to solve it. If anyone
> could help me out this issue will be appreciated.
>
> Thanks,
> Ipsita
>
>
>
> _______________________________________________
> 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/20140918/9b5c2d91/attachment.html
```