Thu 01 Sep 2011 09:16:18 AM UTC, comment #10:
No, the untested suggestion posted in #5 does not produce the output you imagined it would.
# test ability to plot three lines on plotyy() graph
x=y=y2=[1:10];
y3=[6:15];
plotyy(x,y,x,y2);
hold on
plot(x,y3);
hold off
The third line is plotted on the scale of y2 axis but is coloured to indicate it relates to y1 axis. Output is invalid.
Yet again this shows that plotyy() is a hack. This sort of ad hoc . bolt-on solution with unseen, undocumented affects on what axis is "current" etc will be a constant cause of bugs, dysfunction and confusion.
I already suggested that this functionality could probably be incorporated into the existing plot() by simple addition of an option 'axes' =[x1y1,x2y2,x1y2,,x2y1]
This is already available in gnuplot and would require minimal coding to implement.
plot could then return three (or more) args as per plotyy() and remain compatible with existing code expecting one return arg.
from man plot:
Here are some plot examples:
plot (x, y, "@12", x, y2, x, y3, "4", x, y4, "+")
So apparently plot() can already parse an undetermined number of x,y plots with options interspersed.
This would get around all the (undocumented) special cases that occur with the implicit "current axis" paradigm and probably reduce the size of the code base.
The true x2axis could go at the top and actually be a useful feature.
ylabel() and friends could take an explicit optional second arg if they need to be directed to y2axis etc.
The resulting code would probably be simple and easier to maintain (and hopefully document!).
I am fully aware that the current mindset in the project is refractory to outside suggestions (most open source project are run by defensive cliques) but at least this possible solution is logged in the system should anyone wish to fix this mess at some later time.
|