comparison scripts/plot/__plt__.m @ 6172:2de853a110df

[project @ 2006-11-15 22:53:47 by jwe]
author jwe
date Wed, 15 Nov 2006 22:53:48 +0000
parents a3cd9e6fcd9c
children 44c91c5dfe1d
comparison
equal deleted inserted replaced
6171:4508e9d73ea1 6172:2de853a110df
29 29
30 cf = __current_figure__; 30 cf = __current_figure__;
31 mxi = __multiplot_xi__(cf); 31 mxi = __multiplot_xi__(cf);
32 myi = __multiplot_yi__(cf); 32 myi = __multiplot_yi__(cf);
33 33
34 __setup_plot__ ("__gnuplot_plot__"); 34 __setup_plot__ ("plot");
35 35
36 nargs = nargin (); 36 nargs = nargin ();
37 37
38 if (nargs > 1) 38 if (nargs > 1)
39 39
40 k = 1; 40 k = 1;
41 j = __plot_data_offset__{cf}(mxi,myi); 41 j = __plot_data_offset__{cf}(mxi,myi);
42 loff = __plot_line_offset__{cf}(mxi,myi);
43 loff1 = loff;
44 42
45 x_set = false; 43 x_set = false;
46 y_set = false; 44 y_set = false;
47 45
48 ## Gather arguments, decode format, gather plot strings, and plot lines. 46 ## Gather arguments, decode format, gather plot strings, and plot lines.
54 next_arg = {""}; 52 next_arg = {""};
55 else 53 else
56 next_arg = varargin{k++}; 54 next_arg = varargin{k++};
57 endif 55 endif
58 56
59 have_data = false;
60
61 if (ischar (next_arg) || iscellstr (next_arg)) 57 if (ischar (next_arg) || iscellstr (next_arg))
62 if (x_set) 58 if (x_set)
63 [fmt, keystr] = __pltopt__ (caller, next_arg); 59 [fmt, keystr] = __pltopt__ (caller, next_arg);
64 if (y_set) 60 if (y_set)
65 [tdata, tfmtstr, key] = __plt2__ (x, y, fmt, keystr); 61 [tdata, tfmtstr, key] = __plt2__ (x, y, fmt, keystr);
66 else 62 else
67 [tdata, tfmtstr, key] = __plt1__ (x, fmt, keystr); 63 [tdata, tfmtstr, key] = __plt1__ (x, fmt, keystr);
68 endif 64 endif
69 if (! isempty (tdata)) 65 if (! isempty (tdata))
66 for i = 1:numel (tdata)
67 __plot_usingstr__{cf}{mxi,myi}{j}{i} ...
68 = __make_using_clause__ (tdata{i});
69 __plot_withstr__{cf}{mxi,myi}{j}{i} = "";
70 endfor
70 __plot_data__{cf}{mxi,myi}{j} = tdata; 71 __plot_data__{cf}{mxi,myi}{j} = tdata;
71 for i = 1:length (key) 72 __plot_data_type__{cf}{mxi,myi}(j) = 2;
72 __plot_key_labels__{cf}{mxi,myi}{loff1++} = key{i}; 73 __plot_fmtstr__{cf}{mxi,myi}{j} = tfmtstr;
73 endfor 74 __plot_key_labels__{cf}{mxi,myi}{j} = key;
74 fmtstr = tfmtstr; 75 j++;
75 have_data = true;
76 endif 76 endif
77 x_set = false; 77 x_set = false;
78 y_set = false; 78 y_set = false;
79 else 79 else
80 error ("plot: no data to plot"); 80 error ("plot: no data to plot");
82 elseif (x_set) 82 elseif (x_set)
83 if (y_set) 83 if (y_set)
84 [fmt, keystr] = __pltopt__ (caller, {""}); 84 [fmt, keystr] = __pltopt__ (caller, {""});
85 [tdata, tfmtstr, key] = __plt2__ (x, y, fmt, keystr); 85 [tdata, tfmtstr, key] = __plt2__ (x, y, fmt, keystr);
86 if (! isempty (tdata)) 86 if (! isempty (tdata))
87 for i = 1:numel (tdata)
88 __plot_usingstr__{cf}{mxi,myi}{j}{i} ...
89 = __make_using_clause__ (tdata{i});
90 __plot_withstr__{cf}{mxi,myi}{j}{i} = "";
91 endfor
87 __plot_data__{cf}{mxi,myi}{j} = tdata; 92 __plot_data__{cf}{mxi,myi}{j} = tdata;
88 for i = 1:length (key) 93 __plot_data_type__{cf}{mxi,myi}(j) = 2;
89 __plot_key_labels__{cf}{mxi,myi}{loff1++} = key{i}; 94 __plot_fmtstr__{cf}{mxi,myi}{j} = tfmtstr;
90 endfor 95 __plot_key_labels__{cf}{mxi,myi}{j} = key;
91 fmtstr = tfmtstr; 96 j++;
92 have_data = true;
93 endif 97 endif
94 x = next_arg; 98 x = next_arg;
95 y_set = false; 99 y_set = false;
96 else 100 else
97 y = next_arg; 101 y = next_arg;
100 else 104 else
101 x = next_arg; 105 x = next_arg;
102 x_set = true; 106 x_set = true;
103 endif 107 endif
104 108
105 if (have_data)
106 for i = 1:length (__plot_data__{cf}{mxi,myi}{j})
107 usingstr = __make_using_clause__ (__plot_data__{cf}{mxi,myi}{j}{i});
108 __plot_command__{cf}{mxi,myi} ...
109 = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d}{%d} %s %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__(__current_figure__),__multiplot_yi__(__current_figure__)}{%d}",
110 __plot_command__{cf}{mxi,myi},
111 __plot_command_sep__, j, i, usingstr,
112 fmtstr{i}, gnuplot_command_title, loff++);
113 __plot_command_sep__ = ",\\\n";
114 endfor
115 j++;
116 endif
117
118 endwhile 109 endwhile
119 110
120 __plot_data_offset__{cf}(mxi,myi) = j; 111 __plot_data_offset__{cf}(mxi,myi) = j;
121 __plot_line_offset__{cf}(mxi,myi) = loff;
122 112
123 if (__multiplot_mode__(cf)) 113 __render_plot__ ();
124 __gnuplot_raw__ ("clear\n");
125 endif
126
127 if (! strcmp (__plot_command__{cf}{mxi,myi}, "__gnuplot_plot__"))
128 __do_legend__ ();
129 eval (__plot_command__{cf}{mxi,myi});
130 endif
131 114
132 else 115 else
133 msg = sprintf ("%s (y)\n", caller); 116 msg = sprintf ("%s (y)\n", caller);
134 msg = sprintf ("%s %s (x, y, ...)\n", msg, caller); 117 msg = sprintf ("%s %s (x, y, ...)\n", msg, caller);
135 msg = sprintf ("%s %s (x, y, fmt, ...)", msg, caller); 118 msg = sprintf ("%s %s (x, y, fmt, ...)", msg, caller);