bugGNU Octave - Bugs: bug #46835, Error on modifying properties of a...

 
 

bug #46835: Error on modifying properties of a legend in plotyy

Submitted by:  Konstantinos Poulios <logari81>
Submitted on:  Wed 06 Jan 2016 10:33:35 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: ConfirmedAssigned to: Kai Torben Ohlhus <siko1056>
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

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

Renaud GILLON <reginalduck>
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

Pantxo Diribarne <pantxo>
Project Member
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

Kai Torben Ohlhus <siko1056>
Project MemberIn charge of this item.
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.

Kai Torben Ohlhus <siko1056>
Project MemberIn charge of this item.
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)

Konstantinos Poulios <logari81>
Project Member
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.

Konstantinos Poulios <logari81>
Project Member
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"));

Kai Torben Ohlhus <siko1056>
Project MemberIn charge of this item.
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

Konstantinos Poulios <logari81>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #35948:  bug46835.png added by logari81 (38KiB - image/png)
file #35939:  __getlegenddata__.m added by logari81 (2KiB - text/x-objcsrc - Possible fix)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by reginalduck (Posted a comment)
  • -unavailable- added by pantxo (Posted a comment)
  • -unavailable- added by siko1056 (Posted a comment)
  • -unavailable- added by logari81 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 27 Jan 2016 01:22:12 PM UTCsiko1056Item GroupSegfault, Bus Error, etc.=>Incorrect Result
      StatusIn Progress=>Confirmed
      Release4.0.1-rc1=>dev
    Fri 08 Jan 2016 03:05:12 PM UTClogari81Attached File-=>Added bug46835.png, #35948
    Fri 08 Jan 2016 12:21:43 PM UTCsiko1056StatusNone=>In Progress
      Assigned toNone=>siko1056
      Operating SystemGNU/Linux=>Any
    Wed 06 Jan 2016 10:33:35 PM UTClogari81Attached File-=>Added _getlegenddata_.m, #35939

    Back to the top


    Powered by Savane 3.1-cleanup1