# Re: Plot user-defined functions

Date: Mon Sep 30 2013 - 07:40:20 MDT

Hi Anna,

try not using a do loop to plot one value at a time. Before you start
plotting you could try

x = (/0,1,2,3,4/)
T = temp(x)

and then for the plot do

plot1 = gsn_csm_xy(wks, T,x,res)

without the do loop.

Hope this helps,
Maria

>
> I like to creat my own function f(x)= 9.44* 0.0065 *x and I like to plot
> this function.
> I can creat the function and get values for different x. But I can draw
> this function. Can you pleas help me.
> Here is my code and my error message:
> Thanks.
> ;************************************************************
> ;************************************************************
> begin
>
> undef("temp") ;Erstellen von f(x)
> function temp(x)
> begin
> fx = 9.44-0.0065 * x ; Definition von f(x)
> return (fx)
> end
> print(answer) ; Ausgeben der Temperatur
>
> ;***********************************Plot*************************************************************************
> wks_type = "pdf"
> wks = gsn_open_wks(wks_type,"Temperaturprofil1")
> res = True
> res@gsnDraw = False ; don't draw
> res@gsnFrame = False
> ;res@trYReverse = True ;reverser Y-axis
> ;res@trXMinF = 200
> ;res@trXMaxF = 310
> res@tiXAxisString = "Temperatur / K"
> res@tiYAxisString = "Druck / hPa"
> res@xyLineColors =(/"red"/)
> do x=0,4
> plot1 = gsn_csm_xy(wks, temp(x),x,res)
> end do
> draw(plot1)
> frame(wks)
>
> end
> 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: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":8128]:Execute: Error occurred at or near line 11955 in
> file \$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 5016 in
> file \$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 40 in
> file Standardtemp.ncl
>
> _______________________________________________
> 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
Received on Mon Sep 30 07:40:30 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 01 2013 - 14:41:43 MDT