comparison scripts/plot/__plt3__.m @ 6004:01556febbaaf

[project @ 2006-09-26 21:16:52 by jwe]
author jwe
date Tue, 26 Sep 2006 21:16:52 +0000
parents 376e02b2ce70
children eaeff5ddfae5
comparison
equal deleted inserted replaced
6003:7f8e4f5e2eb7 6004:01556febbaaf
31 ## Modified to use NaN as seperator for gnuplot, so multiple calls 31 ## Modified to use NaN as seperator for gnuplot, so multiple calls
32 ## aren't needed. 32 ## aren't needed.
33 ## David Bateman <dbateman@free.fr> 33 ## David Bateman <dbateman@free.fr>
34 ## May 25, 2006 34 ## May 25, 2006
35 35
36 function __plt3__ (x, y, z, fmt) 36 function __plt3__ (x, usingstr, fmtstr, withstr)
37 37
38 if (isvector (x) && isvector (y)) 38 if (nargin < 2)
39 if (isvector (z)) 39 usingstr = "";
40 x = x(:); 40 endif
41 y = y(:); 41 if (nargin < 3)
42 z = z(:); 42 fmtstr = "";
43 elseif (length (x) == rows (z) && length (y) == columns (z)) 43 endif
44 error ("plot3: [length(x), length(y)] must match size(z)"); 44 if (nargin < 4)
45 else 45 withstr = "";
46 [x, y] = meshgrid (x, y);
47 endif
48 endif 46 endif
49 47
50 if (any (size (x) != size (y)) || any (size (x) != size (z))) 48 __plot_globals__;
51 error ("plot3: x, y, and z must have the same shape"); 49
50 __setup_plot__ ("__gnuplot_splot__");
51
52 j = __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__);
53
54 __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j} = x;
55
56 if (iscell (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}))
57 for i = 1:length (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j})
58 if (! isempty(usingstr))
59 length(usingstr)
60 usingstr = __make_using_clause__ (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}{i});
61 endif
62 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \
63 = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s %s",
64 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__},
65 __plot_command_sep__, j, i, usingstr, fmtstr{i});
66 __plot_command_sep__ = ",\\\n";
67 endfor
68 else
69 if (! isempty(usingstr))
70 length(usingstr)
71 usingstr = __make_using_clause__ (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j});
72 endif
73 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \
74 = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s %s %s",
75 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__},
76 __plot_command_sep__, j, usingstr, fmtstr, withstr);
77 __plot_command_sep__ = ",\\\n";
52 endif 78 endif
53 79
54 unwind_protect 80 __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__) = ++j;
55 __gnuplot_set__ parametric;
56 __gnuplot_raw__ ("set nohidden3d;\n");
57 81
58 tmp = [([x; NaN*ones(1,size(x,2))])(:), ... 82 if (__multiplot_mode__)
59 ([y; NaN*ones(1,size(y,2))])(:), ... 83 __gnuplot_raw__ ("clear\n");
60 ([z; NaN*ones(1,size(z,2))])(:)]; 84 endif
61 85
62 eval (sprintf ("__gnuplot_splot__ tmp %s\n", fmt)); 86 if (! strcmp (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, "__gnuplot_splot__"))
63 unwind_protect_cleanup 87 eval (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__});
64 __gnuplot_set__ noparametric; 88 endif
65 end_unwind_protect
66 endfunction 89 endfunction