bugGNU Octave - Bugs: bug #46972, errorbar() example code is...

 
 

bug #46972: errorbar() example code is incorrect

Submitter:  None
Submitted:  Mon 25 Jan 2016 10:07:01 PM UTC
   
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  DoubleDeepIndent Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.2
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 30 Jan 2016 04:24:17 PM UTC, comment #1: 

Yes, the example could be coded more clearly.  I changed both the sample code in the manual and the code that generates the image in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/8b1e030d3d4f).  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Mon 25 Jan 2016 10:07:01 PM UTC, original submission:  

Relevant documentation page:
https://www.gnu.org/software/octave/doc/interpreter/Two_002dDimensional-Plots.html

The example code for errorbar() appears to be incorrect.


x = 0:0.1:10;
y = sin (x);
yp =  0.1 .* randn (size (x));
ym = -0.1 .* randn (size (x));
errorbar (x, sin (x), ym, yp);


should be:


x = 0:0.1:10;
y = sin (x);
yp = 0.1 .* rand (size(x));
ym = 0.1 .* rand (size(x));
errorbar (x, y, ym, yp);


to produce the provided plot.

Per the help docs (which are correct), when plotting lower- and upper-side errors in this way, errorbars are drawn from DATA(n)-LERR(n) to DATA(n)+UERR(n) rather than DATA(n)+LERR(n) to DATA(n)+UERR(n) as the current example code assumes.

Also notice that rand(), rather than randn(), must be used to avoid random positive and negative numbers (not what we want).

Plots produced by the two versions on Octave 3.8.2 are attached.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #36164:  errorbar-bad.png added by None (29KiB - image/png - error-bad.png: current documentation example code output; error-good.png: corrected code output)
file #36165:  errorbar-good.png added by None (29KiB - image/png - error-bad.png: current documentation example code output; error-good.png: corrected code output)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-01-30 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2016-01-25 None Attached File- Added errorbar-bad.png, #36164
        Attached File- Added errorbar-good.png, #36165

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code