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=[3sin(2x), 2.5*cos(x)];
y2=[sin(x/2), 0.9sin(x-0.5), 0.8cos(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)
|
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_:
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:
For axis 2:
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.
|