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.
|
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)
|
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.
|
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.
|
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 ?
|
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)
|
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.
|
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
|
Sun 17 Jul 2011 03:52:37 AM UTC, comment #1:
Confirmed. And it happens with either gnuplot or the FLTK toolkit.
|
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:
|