octave-maintainers
[Top][All Lists]
Advanced

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

Re: snapshot?


From: David Bateman
Subject: Re: snapshot?
Date: Wed, 22 Oct 2008 11:27:40 +0100
User-agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724)

David Bateman wrote:
David Bateman wrote:
John W. Eaton wrote:
I'd like to make a new snapshot soon.  Other than the recent plotting
problems, are there any patches that I've missed which should be
reviewed?

Thanks,

jwe


I'd like to get the group plot objects complete, and have been working on it recently. In particular the "line" object changes need to be re-examined. Also the contour, errorbar, scatter and surface objects need to be evaluated. I basically have all but the errorbar and contour objects done.. Give me a day or so and I'll get the rest done.

Also we should import a new texinfo.tex file and update the build for an examples/@polynomial directory. I have this in the pipeline as well, and am just waiting for a sucessful build before sending a patch.

D.



Ok, I pushed my outstanding changes. Only the contour and errorbar series objects are now missing.

Regards
David




The attached patch also added errorbar series, that I also pushed to Savannah. Note that Octave has the properties ldata, udata, xldata, xudata in the line objects and uses these for errorbar plots. Matlab does not have these properties and hides that fact behind an hggroup that handles the conversion of ldata etc to {x,y}data variables representing the parts of the error bars. So strictly speaking Octave doesn't need an hggroup for an errorbar series. However, Matlab also has two handles for the error bar series (one for the bars and the other for the data) and so it makes sense to duplicate this part in Octave, which is what I did. Eventually, we might want to duplicate the Matlab manner of faking errorbars in the {x,y}data of a line object as this will allow easy implementation with alternative backends, but for now I ignored this issue.

Regards
David



--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary

# HG changeset patch
# User David Bateman <address@hidden>
# Date 1224670888 -3600
# Node ID 67cd36af2bb6a66e814cab85a31813774e8ac744
# Parent  9ad2ed12bc7042156a22e063f242d3d09ce720f9
Add error bar series

diff --git a/doc/ChangeLog b/doc/ChangeLog
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,4 +1,9 @@
 2008-10-22  David Bateman  <address@hidden>
+
+       * interprter/plot.txi: Add documentation for error bar series.
+
+       * interprter/plot.txi: Update documentation for line series, Add 
+       documetation for scatter groups, stem series and surface groups.
 
        * texinfo.tex: Import new upstream version.
        * interpreter/Makefile.in (EXAMPLE_FILES_NODIR): Update for new OOP
diff --git a/doc/interpreter/plot.txi b/doc/interpreter/plot.txi
--- a/doc/interpreter/plot.txi
+++ b/doc/interpreter/plot.txi
@@ -1709,7 +1709,79 @@
 @cindex series objects
 @cindex error bar series
 
-TO BE WRITTEN
+Error bar series are created by the @code{errorbar} function. Each 
address@hidden element contains two line objects represnting the data and
+the errorbars separately. The properties of the error bar series are
+
address@hidden @code
address@hidden color
+The RGB color or color name of the line objects of the error bars. 
@xref{Colors}.
+
address@hidden linewidth
address@hidden linestyle
+The line width and style of the line objects of the error bars. @xref{Line 
Styles}.
+
address@hidden marker
address@hidden markeredgecolor
address@hidden markerfacecolor
address@hidden markersize
+The line and fill color of the markers on the error bars. @xref{Colors}.
+
address@hidden xdata
address@hidden ydata
address@hidden ldata
address@hidden udata
address@hidden xldata
address@hidden xudata
+The original x, y, l, u, xl, xu data of the error bars.
+
address@hidden xdatasource
address@hidden ydatasource
address@hidden ldatasource
address@hidden udatasource
address@hidden xldatasource
address@hidden xudatasource
+Data source variables.
address@hidden table
+
address@hidden Surface group
address@hidden Surface group
address@hidden group objects
address@hidden surface group
+
+Surface group objects are created by the @code{surf} or @code{mesh}
+functions, but are equally one of the handles returned by the @code{surfc}
+or @code{meshc} functions. The surface group is of the type @code{surface}.
+
+The properties of the surface group are
+
address@hidden @code
address@hidden edgecolor
address@hidden facecolor
+The RGB color or color name of the edges or faces of the surface. 
@xref{Colors}.
+
address@hidden linewidth
address@hidden linestyle
+The line width and style of the lines on the surface. @xref{Line Styles}.
+
address@hidden marker
address@hidden markeredgecolor
address@hidden markerfacecolor
address@hidden markersize
+The line and fill color of the markers on the surface. @xref{Colors}.
+
address@hidden xdata
address@hidden ydata
address@hidden zdata
address@hidden cdata
+The original x, y, z and c data.
+
address@hidden xdatasource
address@hidden ydatasource
address@hidden zdatasource
address@hidden cdatasource
+Data source variables.
address@hidden table
 
 @node Line series
 @subsubsection Line series
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,5 +1,8 @@
 2008-10-22  David Bateman  <address@hidden>
 
+       * plot/__errplot__.m: Add errorbar series objects.
+       * plot/errbar.m: Add some demos.
+       
        * plot/__add_line_series__.m: Remove
        * plot/Makefile.in (SOURCES): Remove it here too.
        * plot/__add_datasource__.m: Allow for more than one character in
diff --git a/scripts/plot/__errplot__.m b/scripts/plot/__errplot__.m
--- a/scripts/plot/__errplot__.m
+++ b/scripts/plot/__errplot__.m
@@ -29,67 +29,150 @@
     print_usage ();
   endif
 
-  [fmt, key] = __pltopt__ ("__errplot__", fstr);
+  fstr
+  [fmt, key] = __pltopt__ ("__errplot__", fstr)
 
   [len, nplots] = size (a1);
+  h = [];
 
   for i = 1:nplots
     ## Set the plot type based on linestyle.
-    if (fmt.linestyle == "~")
+
+    if (strcmp (fmt.linestyle, "~"))
       ifmt = "yerr";
-    elseif (fmt.linestyle == ">")
+    elseif (strcmp (fmt.linestyle, ">"))
       ifmt = "xerr";
-    elseif (fmt.linestyle == "~>")
+    elseif (strcmp (fmt.linestyle, "~>"))
       ifmt = "xyerr";
-    elseif (fmt.linestyle == "#")
+    elseif (strcmp (fmt.linestyle, "#"))
       ifmt = "box";
-    elseif (fmt.linestyle == "#~")
+    elseif (strcmp (fmt.linestyle, "#~"))
       ifmt = "boxy";
-    elseif (fmt.linestyle == "#~>")
+    elseif (strcmp (fmt.linestyle, "#~>"))
       ifmt = "boxxy";
     else
       print_usage ();
     endif
 
-    h = __line__ (p);
+    hg = hggroup ("parent", p);
+    h = [h; hg];
+    args = __add_datasource__ ("__errplot__", hg, 
+                              {"x", "y", "l", "u", "xl", "xu"});
+
+    if (isempty (fmt.color))
+      hl = __line__ (hg, "color", __next_line_color__ ());
+    else
+      hl = __line__ (hg, "color", fmt.color);
+    endif
+
+    ## FIXME
+    ## Note the below adds the errorbar data directly as ldata, etc 
+    ## properties of the line objects, as gnuplot can handle this.
+    ## Matlab has the errorbar part of the plot as a special line object
+    ## with embedded NaNs that draws the three segments of the bar
+    ## separately. Should we duplicate Matlab's behavior and stop using the
+    ## ldata, etc properties of the line objects that are Octace specific?
 
     switch (nargin - 2)
+      case 1
+       error ("error plot requires 2, 3, 4 or 6 columns");
       case 2
-       set (h, "xdata", (1:len)');
-       set (h, "ydata", a1(:,i));
-       set (h, "ldata", a2(:,i));
-       set (h, "udata", a2(:,i));
+       set (hl, "xdata", (1:len)');
+       set (hl, "ydata", a1(:,i));
+       set (hl, "ldata", a2(:,i));
+       set (hl, "udata", a2(:,i));
       case 3
-       set (h, "xdata", a1(:,i));
-       set (h, "ydata", a2(:,i));
-       set (h, "ldata", a3(:,i));
-       set (h, "udata", a3(:,i));
+       set (hl, "xdata", a1(:,i));
+       set (hl, "ydata", a2(:,i));
+       set (hl, "ldata", a3(:,i));
+       set (hl, "udata", a3(:,i));
       case 4
-       set (h, "xdata", a1(:,i));
-       set (h, "ydata", a2(:,i));
+       set (hl, "xdata", a1(:,i));
+       set (hl, "ydata", a2(:,i));
 
        if (index (ifmt, "boxxy") || index (ifmt, "xyerr"))
-         set (h, "xldata", a3(:,i));
-         set (h, "xudata", a3(:,i));
-         set (h, "ldata", a4(:,i));
-         set (h, "udata", a4(:,i));
+         set (hl, "xldata", a3(:,i));
+         set (hl, "xudata", a3(:,i));
+         set (hl, "ldata", a4(:,i));
+         set (hl, "udata", a4(:,i));
        elseif (index (ifmt, "xerr"))
-         set (h, "xldata", a3(:,i));
-         set (h, "xudata", a4(:,i));
+         set (hl, "xldata", a3(:,i));
+         set (hl, "xudata", a4(:,i));
        else
-         set (h, "ldata", a3(:,i));
-         set (h, "udata", a4(:,i));
+         set (hl, "ldata", a3(:,i));
+         set (hl, "udata", a4(:,i));
        endif
       case 5
        error ("error plot requires 2, 3, 4 or 6 columns");
       case 6
-       set (h, "xdata", a1(:,i));
-       set (h, "ydata", a2(:,i));
-       set (h, "xldata", a3(:,i));
-       set (h, "xudata", a4(:,i));
-       set (h, "ldata", a5(:,i));
-       set (h, "udata", a6(:,i));
+       set (hl, "xdata", a1(:,i));
+       set (hl, "ydata", a2(:,i));
+       set (hl, "xldata", a3(:,i));
+       set (hl, "xudata", a4(:,i));
+       set (hl, "ldata", a5(:,i));
+       set (hl, "udata", a6(:,i));
     endswitch
+
+    addproperty ("color", hg, "linecolor", get (hl, "color"));
+    addproperty ("linewidth", hg, "linelinewidth", get (hl, "linewidth"));
+    addproperty ("linestyle", hg, "linelinestyle", get (hl, "linestyle"));
+    addproperty ("marker", hg, "linemarker", get (hl, "marker"));
+    addproperty ("markerfacecolor", hg, "linemarkerfacecolor", 
+                get (hl, "markerfacecolor"));
+    addproperty ("markeredgecolor", hg, "linemarkerfacecolor", 
+                get (hl, "markeredgecolor"));
+    addproperty ("markersize", hg, "linemarkersize", 
+                get (hl, "markersize"));
+
+    addlistener (hg, "color", @update_props);
+    addlistener (hg, "linewidth", @update_props); 
+    addlistener (hg, "linestyle", @update_props); 
+    addlistener (hg, "marker", @update_props); 
+    addlistener (hg, "markerfacecolor", @update_props); 
+    addlistener (hg, "markersize", @update_props);
+
+    addproperty ("xdata", hg, "data", get (hl, "xdata"));
+    addproperty ("ydata", hg, "data", get (hl, "ydata"));
+    addproperty ("ldata", hg, "data", get (hl, "ldata"));
+    addproperty ("udata", hg, "data", get (hl, "udata"));
+    addproperty ("xldata", hg, "data", get (hl, "xldata"));
+    addproperty ("xudata", hg, "data", get (hl, "xudata"));
+
+    addlistener (hg, "xdata", @update_data);
+    addlistener (hg, "ydata", @update_data);
+    addlistener (hg, "ldata", @update_data);
+    addlistener (hg, "udata", @update_data);
+    addlistener (hg, "xldata", @update_data);
+    addlistener (hg, "xudata", @update_data);
+
+    __line__ (hg, "xdata", get (hl, "xdata"), 
+             "ydata", get (hl, "ydata"), 
+             "color", get (hl, "color"),
+             "linewidth", get (hl, "linewidth"),
+             "linestyle", get (hl, "linestyle"), 
+             "marker", "none", "parent", hg);
   endfor
 
 endfunction
+
+function update_props (h, d)
+  set (get (h, "children"), "color", get (h, "color"), 
+       "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"), 
+       "marker", get (h, "marker"), "markersize", get (h, "markersize"),
+       "markerfacecolor", get (h, "markerfacecolor"),
+       "markeredgecolor", get (h, "markeredgecolor"));
+endfunction
+
+function update_data (h, d)
+  x = get (h, "xdata");
+  y = get (h, "ydata");
+  l = get (h, "ldata");
+  u = get (h, "udata");
+  xl = get (h, "xldata");
+  xu = get (h, "xudata");
+
+  kids = get (h, "children");
+  set (kids(1), "xdata", x, "ydata", y);
+  set (kids(2), "xdata", x, "ydata", y, "ldata", l, "udata", u, 
+       "xldata", xl, "xudata", xu);
+endfunction
diff --git a/scripts/plot/errorbar.m b/scripts/plot/errorbar.m
--- a/scripts/plot/errorbar.m
+++ b/scripts/plot/errorbar.m
@@ -127,3 +127,9 @@
   end_unwind_protect
 
 endfunction
+
+%!demo
+%! errorbar(0:10,rand(1,11),0.25*rand(1,11))
+
+%!demo
+%! errorbar(0:10,rand(1,11),rand(1,11), ">")

reply via email to

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