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: Mon, 09 Apr 2007 20:28:23 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

John W. Eaton wrote:
On  9-Apr-2007, Daniel J Sebald wrote:

| The baseline that is a child of the axis seems like what I had in mind, i.e., | zero axis line, i.e., something very general that applies to not only stem | plots.

Yes, but that child is just a simple line.  There seems to be nothing
special about it that indicates that it is a "baseline".

| Does stem allow a baseline other than at y=0?

Yes,

  h = stem (-10:10);
  set (h, 'basevalue', 3);

works.

| If so, that would explain the extra baseline handle.

| I'd say, leave out the one that is passed back as a | handle and implement the one that is a child of the axis using the gnuplot | command.

Yes, I think this would be OK, but again, the line that is a child of
the axes object does not appear to be special.

Again, the X data for both the child of the axes object and the
baseline object that is a child of the stemseries object changes when
the axis limits are changed.  So it is not sufficient to have a
special property that is recognized and translated into a special
gnuplot command.  Instead, the data for these objects should be
modified when the limits change and then drawing the lines will
generate the proper plot.  But since there is probably no way to do
this completely right until we have group objects, I think it would be
OK to have the baseline be a child of the axes object and not worry
about resizing it automatically.  I think that is a small bug compared
to not having it as a line object.

Well, that's kind of strange then.  The creation of the baseline can't be in
stem.m using "line()" because the "set" of

  h = stem (-10:10);
  set (h, 'basevalue', 3);

comes after the stem.m.  stem.m would have to pass a handle to set.m somehow and
that would make no sense.

Of course, inside stem.m there can be a "set (h, 'basevalue', 0)" as default.

Well, in any case the attached patch will add back in the baseline. For the same logic of allowing a baseline unadjustable for now, I've also made the baseline unconditional rather than conditioning on, say,

  if (find (y < 0) && find (y > 0))

so that if the y range is expanded, the baseline will be visible.  For example, 
try

 h = stem(0:10);
 set(gca,"xlim",[-1 12]);
 set(gca,"ylim",[-1 12]);

after the patch.

Dan

--- /usr/local/src/octave-cvs/octave/scripts/ChangeLog  2007-04-09 
19:46:52.000000000 -0500
+++ ./ChangeLog 2007-04-09 20:15:08.320764394 -0500
@@ -1,3 +1,8 @@
+2007-04-09  Daniel J. Sebald  <address@hidden>
+
+       * plot/stem.m: Add back the baseline line and let it be not adjustable
+       in response to a change in x limits for now.
+
 2007-04-09  John W. Eaton  <address@hidden>
 
        * plot/__go_draw_axes__.m (__gnuplot_write_data__): New function.
--- /usr/local/src/octave-cvs/octave/scripts/plot/stem.m        2007-04-09 
14:45:26.000000000 -0500
+++ ./stem.m    2007-04-09 20:26:53.981246122 -0500
@@ -113,12 +113,17 @@
   z = zeros (1, numel (x));
   xt = x(:)';
   yt = y(:)';
-  tmp = plot ([xt; xt], [z; yt], "color", lc, "linestyle", ls,
-             x, y, "color", mc, "marker", ms, "linestyle", "",
-             "markerfacecolor", fc);
+  h_stems = plot ([xt; xt], [z; yt], "color", lc, "linestyle", ls,
+                 x, y, "color", mc, "marker", ms, "linestyle", "",
+                 "markerfacecolor", fc);
+
+  ## Must draw the plot first to get proper x limits.
+  drawnow();
+  x_axis_range = get (gca, "xlim");
+  h_baseline = line (x_axis_range, [0, 0], "color", [0, 0, 0]);
 
   if (nargout > 0)
-    h = tmp;
+    h = [h_stems; h_baseline];
   endif
 
 endfunction

reply via email to

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