changeset 6263:d60127449a29

[project @ 2007-02-01 04:07:53 by jwe]
author jwe
date Thu, 01 Feb 2007 04:07:53 +0000
parents e892a83f8840
children cc2bee854d23
files scripts/ChangeLog scripts/plot/__plt2vv__.m scripts/plot/__plt__.m scripts/plot/__uiobject_draw_axes__.m scripts/plot/__uiobject_line_ctor__.m scripts/plot/plot.m
diffstat 6 files changed, 125 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed Jan 31 20:52:55 2007 +0000
+++ b/scripts/ChangeLog	Thu Feb 01 04:07:53 2007 +0000
@@ -1,6 +1,11 @@
 2007-01-31  John W. Eaton  <jwe@octave.org>
 
-	* image/image.m: Don't call drawnow.
+	* plot/__uiobject_draw_axes__.m: Set defaults for color,
+	linestyle, linewidth, marker, and markersize properties.
+	* plot/__uiobject_draw_axes__.m: Attempt to handle line and marker
+	colors and widths, and line styles.
+
+	* plot/__plt__.m, image/image.m: Don't call drawnow.
 
 	* plot/__gnuplot_version__.m: Restore from CVS Attic.
 	* plot/Makefile.in (SOURCES_M): Add it to the list.
--- a/scripts/plot/__plt2vv__.m	Wed Jan 31 20:52:55 2007 +0000
+++ b/scripts/plot/__plt2vv__.m	Thu Feb 01 04:07:53 2007 +0000
@@ -67,6 +67,7 @@
     if (! isempty (key))
       set (h, "key", "on");
     endif
+    fmt{1}
     ## FIXME -- need to handle labels and line format.
     line (x, y, "keylabel", key);
   else
--- a/scripts/plot/__plt__.m	Wed Jan 31 20:52:55 2007 +0000
+++ b/scripts/plot/__plt__.m	Thu Feb 01 04:07:53 2007 +0000
@@ -77,8 +77,6 @@
 
     endwhile
 
-    drawnow ();
-
   else
     msg = sprintf ("%s (y)\n", caller);
     msg = sprintf ("%s       %s (x, y, ...)\n", msg, caller);
--- a/scripts/plot/__uiobject_draw_axes__.m	Wed Jan 31 20:52:55 2007 +0000
+++ b/scripts/plot/__uiobject_draw_axes__.m	Thu Feb 01 04:07:53 2007 +0000
@@ -248,8 +248,10 @@
 	  else
 	    titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\"");
 	  endif
+	  style = do_linestyle_command (obj, data_idx, plot_stream);
 	  usingclause{data_idx} = "";
-	  withclause{data_idx} = "";
+	  withclause{data_idx} = sprintf ("with %s linestyle %d",
+					  style, data_idx);
 	  parametric(i) = true;
 	  if (! isempty (obj.zdata))
 	    nd = 3;
@@ -321,7 +323,8 @@
 		endif
 		data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]';
 		usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)";
-		withclause{data_idx} = "with xyerrorbars";
+		withclause{data_idx} = sprintf ("with xyerrorbars linestyle %d",
+						data_idx);
 	      else
 		if (xautoscale)
 		  xmin = min (xmin, min (xdat));
@@ -330,7 +333,8 @@
 		endif
 		data{data_idx} = [xdat, ydat, ylo, yhi]';
 		usingclause{data_idx} = "using ($1):($2):($3):($4)";
-		withclause{data_idx} = "with yerrorbars";
+		withclause{data_idx} = sprintf ("with yerrorbars linestyle %d",
+						data_idx);
 	      endif
 	    elseif (xerr)
 	      xlo = xdat-xldat;
@@ -348,7 +352,8 @@
 	      endif
 	      data{data_idx} = [xdat, ydat, xlo, xhi]';
 	      usingclause{data_idx} = "using ($1):($2):($3):($4)";
-	      withclause{data_idx} = "with xerrorbars";
+	      withclause{data_idx} = sprintf ("with xerrorbars linestyle %d",
+					      data_idx);
 	    else
 	      if (xautoscale)
 		xmin = min (xmin, min (xdat));
@@ -367,13 +372,15 @@
 
 	case "surface"
 	  data_idx++;
+	  style = do_linestyle_command (obj, data_idx, plot_stream);
 	  if (isempty (obj.keylabel))
 	    titlespec{data_idx} = "";
 	  else
 	    titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\"");
 	  endif
 	  usingclause{data_idx} = "";
-	  withclause{data_idx} = "";
+	  withclause{data_idx} = sprintf ("with %s linestyle %d",
+					  style, data_idx);
 	  parametric(i) = false;
 	  nd = 3;
 	  xdat = obj.xdata;
@@ -653,3 +660,102 @@
   lim = [min_val, max_val];
 
 endfunction
+
+function style = do_linestyle_command (obj, idx, plot_stream)
+
+  fprintf (plot_stream, "set style line %d default;\n", idx);
+  fprintf (plot_stream, "set style line %d", idx);
+
+  found_style = false;
+
+  if (isfield (obj, "color"))
+    color = obj.color;
+    if (isnumeric (color))
+      fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
+	       round (255*color));
+    endif
+    found_style = true;
+  endif
+
+  if (isfield (obj, "linestyle"))
+    switch (obj.linestyle)
+      case "-"
+	lt = "lines";
+      case "--"
+	lt = "";
+      case ":"
+	lt = "";
+      case "-."
+	lt = "";
+      case "none"
+	lt = "";
+      otherwise
+	lt = "";
+    endswitch
+  endif
+
+  if (isfield (obj, "linewidth"))
+    fprintf (plot_stream, " linewidth %f", obj.linewidth);
+    found_style = true;
+  endif
+
+  if (isfield (obj, "marker"))
+    switch (obj.marker)
+      case "+"
+	pt = "1";
+      case "o"
+	pt = "7";
+      case "*"
+	pt = "3";
+      case "."
+	pt = "dots";
+      case "x"
+	pt = "2";
+      case {"square", "s"}
+	pt = "5";
+      case {"diamond", "d"}
+	pt = "13";
+      case "^"
+	pt = "9";
+      case "v"
+	pt = "11";
+      case ">"
+	pt = "8";
+      case "<"
+	pt = "10";
+      case {"pentagram", "p"}
+	pt = "4";
+      case {"hexagram", "h"'}
+	pt = "6";
+      case "none"
+	pt = "";
+      otherwise
+	pt = "";
+    endswitch
+    if (! isempty (pt))
+      fprintf (plot_stream, " pointtype %s", pt);
+      found_style = true;
+    endif
+  endif
+
+  if (isfield (obj, "markersize"))
+    fprintf (plot_stream, " pointsize %f", obj.markersize);
+    found_style = true;
+  endif
+
+  style = "lines";
+  if (isempty (lt))
+    if (! isempty (pt))
+      style = "points"
+    endif
+  elseif (! isempty (pt))
+    style = "linespoints";
+  endif
+
+  if (! found_style)
+    fputs (plot_stream, " default");
+  endif
+
+  fputs (plot_stream, "\n;");
+
+endfunction
--- a/scripts/plot/__uiobject_line_ctor__.m	Wed Jan 31 20:52:55 2007 +0000
+++ b/scripts/plot/__uiobject_line_ctor__.m	Thu Feb 01 04:07:53 2007 +0000
@@ -41,7 +41,12 @@
     s.xldata = [];
     s.xudata = [];
 
-    s.color = [];
+    s.color = [0, 0, 1];
+    s.linestyle = "-";
+    s.linewidth = 0.5;
+
+    s.marker = "none";
+    s.markersize = 1;
 
     s.keylabel = "";
 
--- a/scripts/plot/plot.m	Wed Jan 31 20:52:55 2007 +0000
+++ b/scripts/plot/plot.m	Thu Feb 01 04:07:53 2007 +0000
@@ -175,9 +175,6 @@
 
   newplot ();
 
-  ## [h, varargin] = __plt_get_axis_arg__ ("plot", varargin{:});
-  h = gca ();
-
-  __plt__ ("plot", h, varargin{:});
+  __plt__ ("plot", gca (), varargin{:});
 
 endfunction