Fri 22 Dec 2017 04:16:54 PM UTC, comment #8:
I made a lot of improvements to plotyy and to legend in the last few days on the development branch. The original example seems to work for me now. If some one can confirm I will close this report. Try a cset >= 436deae9f9ab from 2 days ago.
|
Wed 30 Nov 2016 02:20:28 PM UTC, comment #7:
In Octave 4.2.0, when calling legend() after plotyy(), the private function updatelegend() triggers an error when calling set(hax,"units",units) with units being a cellstr.
When modifying the code by adding a loop to index hax(k) and units{k} simultaneously then it works : set(hax(k),"units",units{k}) does not trigger an error.
The loop described above should requires to check first that units is a cell-array of strings...
|
Thu 17 Nov 2016 10:37:49 AM UTC, comment #6:
This bug is still present in the current dev 4.3.0 (39f39eb4e476).
I filed task #14243 about rewriting legend.m
|
Wed 27 Jan 2016 01:22:12 PM UTC, comment #5:
Finally I committed the partial fix to avoid the hard error. But the misbehavior is still present and needs deeper investigation.
http://hg.savannah.gnu.org/hgweb/octave/rev/6f6eae08836f
|
Fri 08 Jan 2016 08:11:24 PM UTC, comment #4:
Yes, I see your point. For what I figured out is that the handles are assigned to the y-axis:
{h1,h3} and {h2,h4,h5}
which is the order printed by default by
>> hl = legend('l1','l2','l3','l4','l5');
If you provide the order of the handles like in comment #3, everything is fine.
Now comes the trouble: set (libinterp/corefcn/graphics.cc) triggers the legend function again, but ignoring any previous legend order, using the default order mentioned above. Other way round: creating a fake legend, font resize and create another legend results in using the default font. Annoying!
Seems like way more work...
Anyway the fix of comment #1 improves the situation a little.
|
Fri 08 Jan 2016 03:05:12 PM UTC, comment #3:
Just for documenting my claim. In the attached file you can see the output of octave after applying Kai's fix.
The correct color order in the legend would be as defined in my original report: red, green, blue, magenta, cyan
So it is the lines that are garbled, not the strings.
Unfortunately the fix of my originally post doesn't work either. It results in "red, blue, green, magenta, cyan", even if it is called with line handles:
>> hl = legend([h1,h2,h3,h4,h5],{'l1','l2','l3','l4','l5'});
(file #35948)
|
Fri 08 Jan 2016 01:08:44 PM UTC, comment #2:
Be careful, that was the first thing that I tried also. The cell2mat fixes the crash but there is still not correct behavior. For some reason the legend strings get reordered. Before you commit a change, please take a look at my fix, attached in the first report. My fix still didn't solve the problem 100% but at least it works when the legend is defined with line handles like:
legend([h1,h2,h3], {'text1','text2','text3'})
while the cell2mat fix as far as I remember it didn't.
|
Fri 08 Jan 2016 12:21:43 PM UTC, comment #1:
I can confirm this. The fix is quite simple, I soon prepare a patch:
>> edit _getlegenddata_
Replace line 32
kids = [get(ca, "children"){:}];
by
kids = cell2mat (get (ca, "children"));
|
Wed 06 Jan 2016 10:33:35 PM UTC, original submission:
>> version
ans = 4.0.1-rc1
>> clf
>> [hax,h1,h2]=plotyy(1:3,2:4,1:3,6:-1:4);
>> hold on
>> [~,h3,h4]=plotyy(1:3,3:5,1:3,5:-1:3);
>> h5=plot(hax(2),1:3,5:7);
>> set(h1,'color','r')
>> set(h2,'color','g')
>> set(h3,'color','b')
>> set(h4,'color','m')
>> set(h5,'color','c')
>> hl = legend('l1','l2','l3','l4','l5');
>> set(hl,'fontsize',14)
error: horizontal dimensions mismatch (2x1 vs 3x1)
error: called from
_getlegenddata_ at line 32 column 10
legend>updatelegend at line 1080 column 17
error: octave_base_value::double_value (): wrong type argument '<unknown type>'
error: octave_base_value::convert_to_str_internal (): wrong type argument '<unknown type>'
error: octave_base_value::convert_to_str_internal (): wrong type argument '<unknown type>'
error: octave_base_value::convert_to_str_internal (): wrong type argument '<unknown type>'
error: octave_base_value::matrix_value(): wrong type argument '<unknown type>'
error: set: A(I,J): row index out of bounds; value 1 out of bound 0
|