bugGNU Octave - Bugs: bug #33757, Legend using DisplayName not...

 
 

bug #33757: Legend using DisplayName not displayed

Submitted by:  None
Submitted on:  Tue 12 Jul 2011 05:43:32 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedAssigned to: None
Originator Name: BurkartOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.4.2
Operating System: GNU/Linux

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 26 Sep 2012 12:40:42 AM UTC, comment #9:

Ben, that's awesome about your child. I expect you will be getting very little sleep for the next 3-6 months.

I'm not sure where your legend2.m script came from. When I diff it against the one in the Mercurial repository there are a lot of changes. When I use the one in the repository there is a single mismatch for the example with 'legend location south'. I'll work on that one.

Rik <rik5>
Project Administrator
Tue 25 Sep 2012 10:21:44 PM UTC, comment #8:

Rik,

I still see some problems. I've attached test script and what Matlab gives.

This week has been up in the air for me (waiting for the birth of my 1st child). So I had some time to experiment ... my free time is soon to end I suspect.

I any event, I've also attached a legend2.m and the result it gives. There is a good possibility that something is broken in legend2.m, but all the demos look ok ... even though there are some differences when compared to Matlab.

(file #26633, file #26634, file #26635, file #26636)

Ben Abbott <bpabbott>
Project Member
Tue 25 Sep 2012 08:54:19 PM UTC, comment #7:

Ben, check out this changeset of mine (http://hg.savannah.gnu.org/hgweb/octave/rev/015cc3d1f389). I think it fixes the Matlab compatability issue with DisplayName.

Rik <rik5>
Project Administrator
Tue 25 Sep 2012 12:18:00 AM UTC, comment #6:

I'd say that a new bug report should be opened since the behavior is different. The bug I fixed was with the behavior of 'show' and 'toggle'. The stuff that you have uncovered is about how the DisplayName property is implemented.

A partial fix doesn't seem too bad. Basically, IF there are no legend names provided AND there are no DisplayName properties on the graphics objects found, then use data1, data2, ..., dataN. Maybe you can verify this again, but why when the legend is created isn't the DisplayName property updated? See the code below, which in Octave definitely sets the DisplayName property.

The other thing to do is to try and figure out where Matlab is holding the labels for the legend if it isn't in the displayName property. My guess is the 'string' property of the legend. Try the following in Matlab.

If this is where they are storing things then the fix isn't that hard. Octave would simply need to write the data1, data2, ... labels into a cellstr in the 'string' property of the legend AND not update the DisplayName properties of the children.

Rik <rik5>
Project Administrator
Mon 24 Sep 2012 11:38:45 PM UTC, comment #5:

hmmm ... the following

is equivalent to

Not likely a quick fix ?

Should this be reopened ?

Ben Abbott <bpabbott>
Project Member
Mon 24 Sep 2012 11:18:13 PM UTC, comment #4:

Rik,

In Matlab, I tried

and obtained the attached result. Since you've just looked over the code, do you see an easy way to implement compatibility and also properly handle cases like below?

(file #26625)

Ben Abbott <bpabbott>
Project Member
Mon 24 Sep 2012 10:43:20 PM UTC, comment #3:

I fixed this in the development branch of Octave in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/1db706430c96). You will need to build from Mercurial sources or wait until the next major release to see the fix.

Rik <rik5>
Project Administrator
Fri 26 Aug 2011 10:09:51 PM UTC, comment #2:

nice trick but it only seems to work for one legend entry, setting two fails in call to legend:

set(h1, 'DisplayName', 'legend key 1');
set(h2, 'DisplayName', 'legend key 2');
legend('right');

error: structure has no member `fontname'
error: evaluating argument list element number 1
error: called from:
error: /usr/share/octave/3.4.0/m/plot/__go_draw_axes__.m at line 2086, column 3
error: /usr/share/octave/3.4.0/m/plot/__go_draw_axes__.m at line 1475, column 31
error: /usr/share/octave/3.4.0/m/plot/__go_draw_figure__.m at line 119, column 21
error: /usr/share/octave/3.4.0/m/plot/__gnuplot_drawnow__.m at line 86, column 5

Anonymous
Sun 17 Jul 2011 03:52:37 AM UTC, comment #1:

Confirmed. And it happens with either gnuplot or the FLTK toolkit.

Rik <rik5>
Project Administrator
Tue 12 Jul 2011 05:43:32 PM UTC, original submission:

It's possible to specify the legend entry for a plot using the DisplayName property. However, if you use that method no legend is shown even when an explicit legend('show') is issued. The only solution I found to make the actual legend visible is to use legend('right'). This shows that the data specified using DisplayName is stored, it's just not evaluated when the plot is initially plotted nor on calling legend('show'). When the legend entry is specified using ';legend entry;' the legend is drawn upon plotting.

Example:

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #26633:  matlab.pdf added by bpabbott (5KiB - application/pdf)
file #26634:  legend2.m added by bpabbott (39KiB - application/octet-stream)
file #26635:  test_legend.m added by bpabbott (361B - application/octet-stream)
file #26636:  legend2.pdf added by bpabbott (5KiB - application/pdf)
file #26625:  legend_show.pdf added by bpabbott (4KiB - application/pdf - plot (rand (3)); legend show)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bpabbott (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by None (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 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 25 Sep 2012 10:21:44 PM UTCbpabbottAttached File-=>Added matlab.pdf, #26633
      Attached File-=>Added legend2.m, #26634
      Attached File-=>Added test_legend.m, #26635
      Attached File-=>Added legend2.pdf, #26636
    Mon 24 Sep 2012 11:18:13 PM UTCbpabbottAttached File-=>Added legend_show.pdf, #26625
    Mon 24 Sep 2012 10:43:20 PM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Sun 17 Jul 2011 03:52:37 AM UTCrik5CategoryPlotting with gnuplot=>Plotting
      StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1