bugGNU Octave - Bugs: bug #48115, __plotyy__ function bug when using...

 
 

bug #48115: __plotyy__ function bug when using FUN2 argument

Submitter:  None
Submitted:  Fri 03 Jun 2016 03:36:06 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Holger Strubelt Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.1
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 23 Nov 2017 05:45:34 PM UTC, comment #4: 

Not changing the color of the y-axis when there is more than one line object is not an error, just a nuisance.  Fixes to the stable branch of Octave are reserved for errors, so I applied the fix for coloring to the development branch of Octave here (http://hg.savannah.gnu.org/hgweb/octave/rev/8a89878ac8bc).  This will eventually be part of the 4.4.0 release.

Thanks for noticing this and suggesting a fix.

Rik <rik5>
Group administrator
Thu 23 Nov 2017 05:23:04 PM UTC, comment #3: 

The error resulting from mismatched dimensions is fixed in this cset on the stable branch (http://hg.savannah.gnu.org/hgweb/octave/rev/e24bf08dc559).  This will be a part of the bug fix release 4.2.2 which should happen at the end/start of this/next year.

Rik <rik5>
Group administrator
Tue 07 Jun 2016 01:29:16 PM UTC, comment #2: 

Encountered the bug when experimenting with assigning different line properties "on-the-fly". Plus, the y-axis coloring issue appeared simultaneously. The behaviour to color an axis only when 1 line is associated to the respective axis is the same as when using a well-known commercial product. See this code example for illustration:

+verbatim
## plotyy examples
x=(0:0.1:10)';
y1=[3*sin(2*x), 2.5*cos(x)];
y2=[sin(x/2), 0.9*sin(x-0.5), 0.8*cos(x/2)];
## plotyy with one line for left y axis => only left y axis should be colored
figure;
plotyy(x,y1(:,1),x,y2);
## plotyy with one line for right y axis => only right y axis should be colored
figure;
plotyy(x,y1,x,y2(:,1));
## plotyy with two inline functions => fails since FUN2 has wrong usage in _plotyy_ function
figure;
plotyy(x,y1,x,y2, ...
       @(x,y) plot(x,y(:,1),'r-',x,y(:,2),'b*'), ...
       @(x,y) plot(x,y(:,1),'g--',x,y(:,2),'m.-',x,y(:,3),'b-.'));

-verbatim

By the way, the second example shows another bug in automatic coloring: the first line in y2 is the same color as the last line in y1. I've also fixed this issue by evaluationg the number of plot lines in y1 before assigning the 'colororder' property to ax(2). This was not included in the original fix provided on Friday.

Added a diff file for all my changes. Not experienced in using diff or naming diff files, so I called it "plotyy_m_diff_u.txt".

Thanks for your help, even though I've already fixed everything myself ;)

(file #37423)

Anonymous
Fri 03 Jun 2016 04:11:05 PM UTC, comment #1: 

@Holger: Thanks for looking at this issue.  First, do you have an example of the bug that can be used for testing?  It is always important to be able to verify the error exists, apply the patch, and re-verify that the error has been corrected.

Second, can supply a unified diff (diff -u) of your changes?  This makes it easier to see what you have modified when reviewing.

Rik <rik5>
Group administrator
Fri 03 Jun 2016 03:36:06 PM UTC, original submission:  

When using a user function (e.g. anonymous function) for the secondary axes used by plotyy, a matrix index error is created.
The bug is in line 134 of function file plotyy.m within function _plotyy_:

h2 = feval (fun2, ax(2), x2, y2);

The second argument ax(2) must be deleted since fun2 is evaluated on the current axes, which is set to ax(2) before that line.
I've attached a corrected version of plotyy.m.

In addition to said bug, I've added an improvement concerning coloring of the y-axes. This doesn't make sense if one of the plot contains multiple lines with different colors, since only the last line will control the y-axis color. So I added a check for the number of lines within the plot:
For axis 1:

  set (ax(1), "color", "none", "xlim", xlim);
  if length(h1) == 1 ## Coloring y-axis only makes sense if plot contains exactly one related line
    set (ax(1), "ycolor", getcolor (h1(1)));
  endif


For axis 2:

  set (ax(2), "yaxislocation", "right", "color", "none", "box", "off", "xlim", xlim);
  if length(h2) == 1 ## Coloring y-axis only makes sense if plot contains exactly one related line
    set (ax(2), "ycolor", getcolor (h2(1)));
  endif


If the maintainer team doesn't follow my argument in this matter, please feel free not to include this change into a new version of plotyy.m.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #37423:  plotyy_m_diff_u.txt added by None (2KiB - text/plain)
file #37377:  plotyy.m added by None (10KiB - text/plain)

 

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)
  • -email is unavailable- added by None (Submitted the item)
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-11-23 rik5 Item GroupNone Matlab Compatibility
        StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2017-11-23 rik5 StatusNeed Info In Progress
    2016-06-07 None Attached File- Added plotyy_m_diff_u.txt, #37423
    2016-06-03 rik5 StatusNone Need Info
    2016-06-03 None Attached File- Added plotyy.m, #37377

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code