Problem retuning graphic object from user defined function

From: Mohamed Abdel Kader <m.abdelkader_at_nyahnyahspammersnyahnyah>
Date: Mon Sep 09 2013 - 12:05:05 MDT

Dear All,
I would like to make a figure of different scatter plots super-imposed a global map. I have a user defined function that generates the scatter plots and I return the scatter plot graphic object. The returned graphic object has missing value.
I have to do in that way since the scatter plot is highly customized and it's being called many times from different scripts. So, I would like to keep one scatter plot script. Could you please help me on solving this problem.
 
I attached parts from the script.
P.S.: The scatter function works fine as standalone

Thanks a lot and let me know if you need more information.

========================================================================================================================
Scatter plot function:
function Plot_Scatter_function(x_title:string,y_title:string,data_x:numeric,data_y:numeric,f_name:string,data_set_string:string, ps_op:logical, plot:graphic)
local plot1, plot2
begin
.
.
.
. "many commands"
.
.
       wks = gsn_open_wks("eps", f_name )

                plot1 = gsn_csm_xy (wks,ndtooned(data_x),ndtooned(data_y),res)
                plot2 = gsn_csm_xy (wks,(/res@trXMinF,res@trXMaxF/),(/res@trYMinF,res@trYMaxF/),res2)

        overlay(plot1,plot2)
        draw(plot1)
        frame(wks)
        print(plot1)
        plot=plot1
      return (plot)
end

the print out from scatter function
Variable: plot
Type: obj
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 2
  dataspec : /EMAC_map_scatter_____tmp_data xyDataSpecClass 89
  data : /EMAC_map_scatter_____tmp_data coordArraysClass 67
(0) /EMAC_map_scatter_____tmp_xy xyPlotClass 88
========================================================================================================================

Parent script:
.
.
.
.
dum_poly = new(NREG,graphic)

do n=0,NREG-1
             dum_poly(n)= Plot_Scatter_function(x_title,y_title,data_xx,data_yy,f_name+"_____tmp",data_set_string, ps_op,dum_poly(n))
             ann = gsn_add_annotation (map,dum_poly(n),amres)
end do
.
.
.
.
.
.
end

the message error

warning:NhlAddAnnotation: bad HLU id passed in, ignoring it
fatal:_NclAddHLURef: internal error: ncl object 647412112 does not exist for vname anno_id
fatal:_NclAddHLURef: internal error: ncl object 647412112 does not exist for vname ann

The print out of dum_poly(n): from the Parent script.
Variable: dum_poly
Type: obj
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 3
  data : -1
  dataspec : -1
  _FillValue : -1
(0) -1
========================================================================================================================

Best Regards
Mohamed M. Abdel Kader
Atmosphere and Climate Modelling Group
Research Assistant/PhD student
Environmental & Atmospheric Sciences
Max-Planck Institute for Atmospheric chemistry, Germany
The Cyprus Institute, Cyprus
20 Constantinou Kavafi Street
P.O. Box: 27456
Nicosia 2121, Cyprus
Tel. +357 222 08679
Fax. +357 222 08625
Mobile: +357 992 62108
e-mails: m.abdelkader@cyi.ac.cy
mmkader@gmail.com
Skype: mmkader

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Sep 9 12:05:55 2013

This archive was generated by hypermail 2.1.8 : Mon Sep 16 2013 - 13:43:52 MDT