[ncl-talk] error in scatter xy3 plot/ regression line

Amal Inge amalingenieur89 at gmail.com
Fri Jan 18 16:23:20 MST 2019


Hi Adam,
Now it works like this but as you see in the plot, the colors are not
setting correctly (my variables in 1D, y_a1 should have blue,y_b1 gold,y_c1
green same for data2):

data1      =(/y_a1,y_b1,y_c1/)
 x = (/1,1.3,1.6/)
plot = gsn_csm_xy(wks,x,data1,res)
data2      =(/y_a3,y_b3,y_c3/)
x2 =(/2,2.3,2.6/)
plot1 = gsn_csm_xy(wks, x2, data2, res)
res at xyMonoMarkerColor  = False
res at xyMarkerColors     = (/"blue",\
                                 "gold",\
                              "green"/)


Le ven. 18 janv. 2019 à 21:51, Adam Phillips <asphilli at ucar.edu> a écrit :

> Hi Amal,
> If I understand you correctly, you're saying that inputting an x-array of
> dimension size 1 works with a bar chart but not a scatter plot? A short
> test here shows that turning gsnXYBarChart on and off results in the same
> error when you input a x-array of dimension size 1:
>
> begin
>  f = addfile ("SOI.nc", "r")      ; add file
>  date  = f->yyyymm                 ; YYYYMM
>  dsoik = f->SOI_SIGNAL
>  wks   = gsn_open_wks ("png", "bar" )  ; send graphics to PNG file
>  res = True
>  res at gsnXYBarChart = True
>  res at gsnXYBarChartBarWidth = 0.25
> res at tiYAxisString = "Oxygen(millimol/m3) and Landing (10e2Ton)"
>  res at tmXBLabelAngleF = 70
> res at tmXBLabelFontHeightF = 0.012
>  res at tiMainString = "Oxygen and Landing in Med GSAs"
>  res at gsnXYBarChartColors = "blue"
>  plots1 = gsn_csm_xy(wks, date(0), dsoik, res)
> end
>
> I get the same error message either way:
> (0) gsn_csm_xy: Fatal: X and Y must have the same dimensions sizes, or
> one must be one-dimensional and both have the same rightmost dimension.
>
> If you continue to have problems please provide a short, easy-to-run
> script that highlights the issue for all to see, as well as report which
> version of NCL you are running.
> Adam
>
>
> On Fri, Jan 18, 2019 at 1:29 AM Amal Inge <amalingenieur89 at gmail.com>
> wrote:
>
>> Thanks Adam, but please have a look at this bar charts plot i did it with
>> the script attached and it works with:
>>  res at gsnXYBarChartColors = "blue"
>>  plots1 = gsn_csm_xy(wks, x, y_a1, res)
>>  res at gsnXYBarChartColors = "gold"
>>  plots2 = gsn_csm_xy(wks, x+0.15, y_b1, res)
>>  res at gsnXYBarChartColors = "green"
>>  plots3 = gsn_csm_xy(wks, x+0.30, y_c1, res)
>>  I want to do the same in a scatter plot and to add 2 other y axis.
>> I could not recognize my mistake!
>>  dox_AllGSAs_2014landing.eps
>> <https://drive.google.com/file/d/1hD9GiUCEqvOsbj7O3a4AxyzkfRK2wx22/view?usp=drive_web>
>>
>>
>> Le jeu. 17 janv. 2019 à 23:35, Adam Phillips <asphilli at ucar.edu> a
>> écrit :
>>
>>> Hi Amal,
>>> Looking at your script, line 66 is this:
>>> plots1 = gsn_csm_xy(wks,x,y_a1,res)
>>> So NCL is failing on the plot call. Looking at how you are setting x and
>>> y_a1:
>>>  y_a1 = dim_avg_n_Wrap(dox_ave_a1,(/1,2/))
>>> x = (/1/)
>>>
>>> NCL returned a list of error messages to you, but the most important one
>>> is the first one:
>>> fatal:CheckArray:Each vector in the caXArray array must have at least 2
>>> elements
>>>
>>> Your x array has one element. Assyming y_a1 is a 1D array containing
>>> values at each timestep, your input array "x" should contain the times that
>>> you want to plot the timeseries against. A typical example of using
>>> gsn_csm_xy on an annual timeseries that runs from 1900-2017:
>>> plot = gsn_csm_xy(wks,ispan(1900,2017,1),tseries,res)
>>>
>>> Hope that helps. If you have any further questions please let the
>>> ncl-talk email list know.
>>> Adam
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Jan 17, 2019 at 8:03 AM Amal Inge <amalingenieur89 at gmail.com>
>>> wrote:
>>>
>>>> sorry, this is the error:
>>>> fatal:CheckArray:Each vector in the caXArray array must have at least 2
>>>> elements
>>>> fatal:CoordArraysInitialize:caXArray resource is invalid
>>>> fatal:Unable to initialize layer-Can't Create
>>>> fatal:Unable to access object with id:-4
>>>> fatal:PID #-4 can't be found in NhlSetValues
>>>> fatal:Unable to access object with id:-4
>>>> warning:Unable to add DataItem "(null)" to DataList "xyCoordData"
>>>> fatal:CompileDataList:DataList has no valid members
>>>> fatal:Unable to access object with id:-4
>>>> warning:Unable to add DataItem "(null)" to DataList "xyCoordData"
>>>> fatal:CompileDataList:DataList has no valid members
>>>> fatal:Argument type mismatch on argument (0) of (attsetvalues_check)
>>>> can not coerce
>>>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 12478
>>>> in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
>>>>
>>>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 5083
>>>> in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>>>
>>>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 66 in
>>>> file dox-landing-xy.ncl
>>>>
>>>>
>>>> Le jeu. 17 janv. 2019 à 13:37, Amal Inge <amalingenieur89 at gmail.com> a
>>>> écrit :
>>>>
>>>>> Dear NCL experts,
>>>>>
>>>>> I tried this script attached to make a scatter plot with 3 y axis,
>>>>> then I had this error and i did not find my mistake.
>>>>> Could you help me please.
>>>>> I checked the script scatter_4.ncl to make a 2 regresseion line (one
>>>>> between all dox data and y2 and the second with y3) but i did not
>>>>> understand how to deal with this, it would be nice if you can tell me how.
>>>>> exemple of variable:
>>>>> Variable: y_a1
>>>>> Type: float
>>>>> Total Size: 4 bytes
>>>>>             1 values
>>>>> Number of Dimensions: 1
>>>>> Dimensions and sizes: [time | 1]
>>>>> Coordinates:
>>>>>             time: [1402876800..1402876800]
>>>>> Number Of Attributes: 7
>>>>>   _FillValue : 1e+20
>>>>>   standard_name :
>>>>> mole_concentration_of_dissolved_molecular_oxygen_in_sea_water
>>>>>   long_name : Mole concentration of Dissolved Molecular Oxygen in sea
>>>>> water
>>>>>   units : millimol m-3
>>>>>   _ChunkSizes : ( 1, 22, 84, 161 )
>>>>>   average_op_ncl : dim_avg_n over dimension(s): lat,lon
>>>>>   missing_value : 1e+20
>>>>>
>>>>> many thanks
>>>>> best regards
>>>>> amal
>>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>
>>>
>>> --
>>> Adam Phillips
>>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>>>
>>> <http://www.cgd.ucar.edu/staff/asphilli>
>>>
>>
>
> --
> Adam Phillips
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>
> <http://www.cgd.ucar.edu/staff/asphilli>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190119/b1ccb5aa/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.eps
Type: image/x-eps
Size: 585214 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190119/b1ccb5aa/attachment-0001.bin>


More information about the ncl-talk mailing list