diff scripts/plot/__plt__.m @ 6146:1a6d826e92b5

[project @ 2006-11-09 03:13:11 by jwe]
author jwe
date Thu, 09 Nov 2006 03:15:23 +0000
parents 01556febbaaf
children 8614649c454c
line wrap: on
line diff
--- a/scripts/plot/__plt__.m	Wed Nov 08 20:34:01 2006 +0000
+++ b/scripts/plot/__plt__.m	Thu Nov 09 03:15:23 2006 +0000
@@ -27,6 +27,10 @@
 
   __plot_globals__;
 
+  cf = __current_figure__;
+  mxi = __multiplot_xi__;
+  myi = __multiplot_yi__;
+
   __setup_plot__ ("__gnuplot_plot__");
 
   nargs = nargin ();
@@ -34,7 +38,9 @@
   if (nargs > 1)
 
     k = 1;
-    j = __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__);
+    j = __plot_data_offset__{cf}(mxi,myi);
+    loff = __plot_line_offset__{cf}(mxi,myi);
+    loff1 = loff;
 
     x_set = false;
     y_set = false;
@@ -45,23 +51,26 @@
 
       if (nargs == 0)
 	## Force the last plot when input variables run out.
-	next_arg = "";
+	next_arg = {""};
       else
 	next_arg = varargin{k++};
       endif
 
       have_data = false;
 
-      if (ischar (next_arg))
+      if (ischar (next_arg) || iscellstr (next_arg))
 	if (x_set)
-	  fmt = __pltopt__ (caller, next_arg);
+	  [fmt, keystr] = __pltopt__ (caller, next_arg);
 	  if (y_set)
-	    [tdata, tfmtstr] = __plt2__ (x, y, fmt);
+	    [tdata, tfmtstr, key] = __plt2__ (x, y, fmt, keystr);
 	  else
-	    [tdata, tfmtstr] = __plt1__ (x, fmt);
+	    [tdata, tfmtstr, key] = __plt1__ (x, fmt, keystr);
 	  endif
 	  if (! isempty (tdata))
-	    __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j} = tdata;
+	    __plot_data__{cf}{mxi,myi}{j} = tdata;
+	    for i = 1:length (key)
+	      __plot_key_labels__{cf}{mxi,myi}{loff1++} = key{i};
+	    endfor
 	    fmtstr = tfmtstr;
 	    have_data = true;
 	  endif
@@ -72,10 +81,13 @@
 	endif
       elseif (x_set)
 	if (y_set)
-	  fmt = __pltopt__ (caller, "");
-	  [tdata, tfmtstr] = __plt2__ (x, y, fmt);
+	  [fmt, keystr] = __pltopt__ (caller, {""});
+	  [tdata, tfmtstr, key] = __plt2__ (x, y, fmt, keystr);
 	  if (! isempty (tdata))
-	    __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j} = tdata;
+	    __plot_data__{cf}{mxi,myi}{j} = tdata;
+	    for i = 1:length (key)
+	      __plot_key_labels__{cf}{mxi,myi}{loff1++} = key{i};
+	    endfor
 	    fmtstr = tfmtstr;
 	    have_data = true;
 	  endif
@@ -91,35 +103,30 @@
       endif
 
       if (have_data)
-	if (iscell (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}))
-	  for i = 1:length (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j})
-	    usingstr = __make_using_clause__ (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}{i});
-	    __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \
-		= sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s %s",
-			   __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__},
-			   __plot_command_sep__, j, i, usingstr, fmtstr{i});
-	    __plot_command_sep__ = ",\\\n";
-	  endfor
-	else
-	  usingstr = __make_using_clause__ (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j});
-	  __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \
-	    = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s %s",
-		       __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__},
-		       __plot_command_sep__, j, usingstr, fmtstr);
+	for i = 1:length (__plot_data__{cf}{mxi,myi}{j})
+	  usingstr = __make_using_clause__ (__plot_data__{cf}{mxi,myi}{j}{i});
+	  __plot_command__{cf}{mxi,myi} ...
+	      = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s %s %s __plot_key_labels__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}",
+			 __plot_command__{cf}{mxi,myi},
+			 __plot_command_sep__, j, i, usingstr,
+			 fmtstr{i}, gnuplot_command_title, loff++);
 	  __plot_command_sep__ = ",\\\n";
-	endif
+	endfor
 	j++;
       endif
 
     endwhile
 
-    __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__) = j;
+    __plot_data_offset__{cf}(mxi,myi) = j;
+    __plot_line_offset__{cf}(mxi,myi) = loff;
 
     if (__multiplot_mode__)
       __gnuplot_raw__ ("clear\n");
     endif
-    if (! strcmp (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, "__gnuplot_plot__"))
-      eval (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__});
+
+    if (! strcmp (__plot_command__{cf}{mxi,myi}, "__gnuplot_plot__"))
+      __do_legend__ ();
+      eval (__plot_command__{cf}{mxi,myi});
     endif
 
   else