octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stem update, rough guess.


From: Daniel J Sebald
Subject: Re: Stem update, rough guess.
Date: Fri, 06 Apr 2007 18:22:47 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

Shai Ayal wrote:
On 4/6/07, John W. Eaton <address@hidden> wrote:

Checking that the color is not empty is the thing to do.

OK; as it is then.

| Also, I don't really follow the hh, hhh, hhhh handle stuff.  My way
| of thinking is that plot() should now assign that correctly if
| everything is done with one plot command.  So I've put comment
| characters in front of all those lines and someone else can evaluate
| if that is really needed.

I don't know what that is all about either.  We should probably be
setting the markerfacecolor property if dofill is true, but that
property is not handled in the graphics.cc file or by __go_draw_axes__

The stem.m help doesn't indicate what "fill" means. I don't know how one fills a stem plot. Color in the circle? But that is a different symbol in the list of options. (There is mention of "bar" in the help, maybe that is what fill pertains to.)

yet.  I have no idea what the intent was for plotting an additional
line using the axis limits.


The intent: If the plotted vector has both negative and positive
values (say sin(1:10)) this would plot a line at y=0 to show where the
axis zero is. Why this is important I do not know. Maybe it's a Matlab
compatibility thing ?

OK, yes that is this part:

#  if (find (y < 0))
#    x_axis_range = get (gca, "xlim");
#    hhhh = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
# endif

In gnuplot that is handled with a separate "set", and I'm guessing this axis line might be a property for the matryoshka pointers. So, what I've done in the attached patch is use the fputs/__plot_stream__ mechanism as an illustration. I've made the line half size so it doesn't stand out so. If this makes sense, then this can be moved into __go_draw_axes__ with some new type of property.

Now, in the examples for stem.m I see this one:

## @example
## x = 1:10;
## y = ones (size (x))*2.*x;
## h = stem (x, y, "b");
## @end example
## @noindent
## plots 10 bars with heights from 2 to 20

Bars are certainly possible with gnuplot, but isn't "b" conflicting with the plot option "blue" which is "b"?

Dan
--- /usr/local/share/octave/2.9.10+/m/plot/stem.m       2007-04-05 
16:23:29.000000000 -0500
+++ ./stem.m    2007-04-06 18:19:35.923707853 -0500
@@ -19,7 +19,7 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} address@hidden =} stem (@var{x}, @var{y}, 
@var{linespec})
-## Plot a stem graph and return the handles of hte line and marker
+## Plot a stem graph and return the handles of the line and marker
 ## objects used to draw the stems.  The default color is @code{"r"}
 ## (red). The default line style is @code{"-"} and the default marker is
 ## @code{"o"}.
@@ -30,7 +30,7 @@
 ## stem (x);
 ## @end example
 ## @noindent
-## plots 10 stems with hights from 1 to 10;
+## plots 10 stems with heights from 1 to 10;
 ##
 ## @example
 ## x = 1:10;
@@ -38,7 +38,7 @@
 ## stem (x, y);
 ## @end example
 ## @noindent
-## plots 10 stems with hights from 2 to 20;
+## plots 10 stems with heights from 2 to 20;
 ## 
 ## @example
 ## x = 1:10;
@@ -46,7 +46,7 @@
 ## h = stem (x, y, "b");
 ## @end example
 ## @noindent
-## plots 10 bars with hights from 2 to 20
+## plots 10 bars with heights from 2 to 20
 ## (the color is blue, and @var{h} is a 2-by-10 array of handles in
 ## which the first row holds the line handles and the 
 ## the second row holds the marker handles);
@@ -57,7 +57,7 @@
 ## h = stem (x, y, "-.k");
 ## @end example
 ## @noindent
-## plots 10 stems with hights from 2 to 20
+## plots 10 stems with heights from 2 to 20
 ## (the color is black, line style is @code{"-."}, and @var{h} is a 2-by-10
 ## array of handles in which the first row holds the line handles and
 ## the second rows holds the marker handles);
@@ -68,7 +68,7 @@
 ## h = stem (x, y, "-.k.");
 ## @end example
 ## @noindent
-## plots 10 stems with hights from 2 to 20
+## plots 10 stems with heights from 2 to 20
 ## (the color is black, line style is @code{"-."} and the marker style
 ## is @code{"."}, and @var{h} is a 2-by-10 array of handles in which the
 ## first row holds the line handles and the second row holds the marker
@@ -80,7 +80,7 @@
 ## h = stem (x, y, "fill");
 ## @end example
 ## @noindent
-## plots 10 stems with hights from 2 to 20
+## plots 10 stems with heights from 2 to 20
 ## (the color is rgb-triple defined, the line style is @code{"-"},
 ## the marker style is @code{"o"}, and @var{h} is a 2-by-10 array of
 ## handles in which the first row holds the line handles and the second
@@ -102,42 +102,38 @@
 
   [x, y, dofill, lc, ls, mc, ms] = check_stem_arg (varargin{:});
 
-  newplot ();
+  ## FIXME:  If marker that can be filled, choose the filled option.  This
+  ## isn't the best way to do this.  Remove when the "markerfacecolor" option
+  ## below is fully implemented.
+  if (dofill)
+    if (ms == "o")
+      ms = ".";
+    elseif (ms == ">")
+      ms = "^";
+    elseif (ms == "<")
+      ms = "v";
+    elseif (ms == "p")
+      ms = "s";
+    endif
+  endif
 
-  ## first, plot the lines.. without marker
-  ## Use a loop and calls to line here because setting properties this
-  ## way doesn't work with plot yet.
-  idxhh = 0;
-  for i = 1:numel(x)
-    hh(++idxhh) = line ([x(i); x(i)], [0; y(i)], "color", lc, "linestyle", ls);
-  endfor
+  newplot ();
 
-  ## second, plot the markers..
-  hhh = [];
-  hhhh = [];
-
-  ## Use a loop and calls to line here because setting properties this
-  ## way doesn't work with plot yet.
-  idxhhh = 0;
-  for i = 1:numel(x)
-    hhh(++idxhhh) = line ([x(i); x(i)], [y(i); y(i)]);
-  endfor
+  h = plot ([x(:) x(:)]', [zeros(size(x(:))) y(:)]', "color", lc, "linestyle", 
ls, x, y, "color", mc, "marker", ms, "linestyle", "");
 
-  if (find (y < 0))
-    x_axis_range = get (gca, "xlim");
-    hhhh = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
-  endif
+  ## FIXME:  A property should be added to the handle list for the following.
+#  set (gca, "?axisline?", "on");
+  ## Note that the first time this is called, the __plot_stream__ = []
+  ## so there will be an error.  (Could the plot stream be initialized inside
+  ## newplot.m rather than __go_draw_axes__.m?)
+#  fputs( get (gcf, "__plot_stream__"), "set xzeroaxis;\nreplot;\n");
+  fputs( get (gcf, "__plot_stream__"), "set xzeroaxis linetype -1 linewidth 
0.5;\nreplot;\n");
 
   if (dofill)
-    set (hhh, "markerfacecolor", mc);
+    set (h, "markerfacecolor", mc);
   endif
 
-  if (nargout > 0)
-    if (! isempty (hhhh))
-      hhhh = hhhh*(ones (length (hh), 1))';
-    endif
-    h = [hh; hhh; hhhh];
-  endif
+  ## FIXME:  WHAT IS A HANDLE GROUP THAT SHOULD BE RETURNED?
 
 endfunction
 
@@ -279,11 +275,11 @@
   for i = 1:length(cur_props)
     if (isfield (cur_props(i), "markeredgecolor"))
       mc = cur_props(i).markeredgecolor;
-    elseif (isfield (cur_props(i), "color")); # means line color
+    elseif (isfield (cur_props(i), "color") && ! isempty 
(cur_props(i).color)); # means line color
       lc = cur_props(i).color;
     elseif (isfield (cur_props(i), "linestyle"))
       ls = cur_props(i).linestyle;
-    elseif (isfield (cur_props(i), "marker"))
+    elseif (isfield (cur_props(i), "marker") && ! strcmp (cur_props(i).marker, 
"none"))
       ms = cur_props(i).marker;
     endif
   endfor

reply via email to

[Prev in Thread] Current Thread [Next in Thread]