bugGNU Octave - Bugs: bug #32343, last plot resets all other curve...

 
 

bug #32343: last plot resets all other curve labels

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Thu 03 Feb 2011 09:28:16 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  dbateman
Originator Name:  Dmitri Sergatskov Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 06 Feb 2011 07:48:01 PM UTC, comment #14: 

I'll file a new bug report.

Ben Abbott <bpabbott>
Group Member
Sun 06 Feb 2011 06:38:59 PM UTC, comment #13: 

The patch in David's comment seems to have
fixed this.  legend definitely has enough
complicated options to confuse both implementers
and users.  We can blame that on Matlab.

So, unless others find more problems, I would
say that we can keep this closed.

Good to have this fixed before the release.
Thanks David!

Michael Godfrey <godfrey>
Group Member
Sun 06 Feb 2011 02:44:21 PM UTC, comment #12: 

I see some remaining problems.

I notice that "legend off" does not return the axis position to its original values.

There is also an inconsistency with Matlab.

When the legend's position is "northeastoutside", the axis position adjusts downward and to the left for me. Matlab only adjust to the left. I think the Matlab approach is to align the top of the axes objects.

Should new bug reports be opened?

Ben Abbott <bpabbott>
Group Member
Sun 06 Feb 2011 02:33:54 PM UTC, comment #11: 

If fact I don't think this is the same bug and in fact its two separate bugs.. I believe the changeset

http://hg.savannah.gnu.org/hgweb/octave/rev/cf9ca0dbc5ee

fixes these issues

D.

David Bateman <dbateman>
Group Member
Sun 06 Feb 2011 02:24:03 PM UTC, comment #10: 

I see the same effect as Michael, and have added another demo.


close all
graphics_toolkit fltk
demo ("legend", 18)


I've also attached a plot.

(file #22609)

Ben Abbott <bpabbott>
Group Member
Sun 06 Feb 2011 08:07:52 AM UTC, comment #9: 

The end of my previous commnet got cut off.

It said:
error: called from:
error:   /usr/local/share/octave/3.5.0+/m/plot/legend.m at line 396, column 19
octave:2>
=======================================

Same as example 3, but the last command fails.  So, there
is something random happening.  The may be an initialization
problem.

I recommend reopening this report.

Michael Godfrey <godfrey>
Group Member
Sun 06 Feb 2011 08:05:59 AM UTC, comment #8: 

There still appear to be problems with
legend() using fltk.  Some commands fail
that should work, and the behavior of commands depends
on previous commands.

Examples:
Example 1:
octave:1> plot(1:200)
octave:2> legend({"hello world"}, "location", "northeastoutside");
octave:3> legend({"hello world"}, "location", "northeastoutside");
octave:4>
===============

Each legend command shrinks the plot to the left.


Example 2:
octave:1> plot(1:200)
octave:2> legend({"hello world"}, "location", "northeastoutside");
octave:3> legend({"hello world"}, "location", "southeastoutside");
error: invalid value for array property "position"
error: called from:
error:   /usr/local/share/octave/3.5.0+/m/plot/legend.m at line 640, column 11
octave:3> legend({"hello world"}, "location", "northeastoutside");
octave:4> quit
===============================
Command fails that should be OK. But, following command
works.

Example 3:

octave:1> plot(1:200)
octave:2> legend({"hello world"}, "location", "southeastoutside");
error: invalid value for array property "position"
error: called from:
error:   /usr/local/share/octave/3.5.0+/m/plot/legend.m at line 640, column 11
octave:2> legend({"hello world"}, "location", "northeastoutside");
error: get: unknown axes property textposition
                                                                                                                     1,1           Top

Michael Godfrey <godfrey>
Group Member
Sat 05 Feb 2011 03:47:41 PM UTC, comment #7: 

Ok closed
D.

David Bateman <dbateman>
Group Member
Sat 05 Feb 2011 03:25:50 PM UTC, comment #6: 

Thanks for looking at this problem.  I assumed that the listeners were there for some reason, but it wasn't clear to me what was causing the trouble.

I pushed the change.

OK to close the two bug reports?

John W. Eaton <jwe>
Group administrator
Fri 04 Feb 2011 10:58:07 PM UTC, comment #5: 

John,

The listener functions are needed to allow things like

plot(1:2, "-r")
h = legend("I am red")
set (h, "location", "east")

to work as expected. I believe the issue is rather that in _plt_ we aren't taking into account any existing legends when called. So the fix is  to correctly initialize hlgnd and tlgnd in _plt_. Ben's original fix worked for #32022 because he explicitly set the correct axis handle and effectively removed the call to fliplr.

Adding fliplr again works for #32343 because the second call to _plt_ and the embedded second call to the legend function makes the "2" legend key be assigned to the last key set. However this won't work for a case like

plot (1:3,"-r;1;");hold on; plot(2*(1:3),"-g;2;",3*(1:3),"-r;3;")

as the second and third labels will be reversed. Note that flipud and fliplr shouldn't be needed at all.

I believe the attached changeset fixes this issue, but I haven't pushed it yet.

D.


(file #22608)

David Bateman <dbateman>
Group Member
Fri 04 Feb 2011 08:44:18 PM UTC, comment #4: 

Is the updatelegend function even needed?  If I remove the addlistener commands for it, the demos all seem to work, and the problem reported here goes away.  See the attached diff for my changes.  Can someone give me an example where the updatelegend listener is needed?

David, will you please comment on this problem?


(file #22607)

John W. Eaton <jwe>
Group administrator
Fri 04 Feb 2011 12:34:53 AM UTC, comment #3: 

Ouch!

I don't recall the details, but I think this originally came about after David's work on the legend. I thought my attempt had worked, but apparently not.

I've cc'd David in case he has something more useful to add than I.

Ben Abbott <bpabbott>
Group Member
Thu 03 Feb 2011 10:52:52 PM UTC, comment #2: 

The bug was introduced in this changeset when another bug was fixed:

http://hg.savannah.gnu.org/hgweb/octave/rev/1f54ee6760b5

I'm copying Ben since he made the change.

the change was simple, just


@@ -774,8 +775,9 @@
   persistent recursive = false;
   if (! recursive)
     recursive = true;
+    hax = getfield (get (h, "userdata"), "handle");
     [hplots, text_strings] = getlegenddata (h);
-    h = legend (fliplr (hplots), get (h, "string"));
+    h = legend (hax, flipud (hplots), get (h, "string"));
     recursive = false;
   endif
 endfunction


in legend.m.  I'm not sure why flipud is used here since my tests show that hplots is a row vector, so flipud has no effect.

If I go back to fliplr, then the bug reported here (#32343) is fixed, but the bug reported in #32022 reappears.

I don't know what the proper fix is.


John W. Eaton <jwe>
Group administrator
Thu 03 Feb 2011 09:47:22 PM UTC, comment #1: 

Since it works in 3.3.54 but not in 3.3.55, I'm bisecting to see what change caused the problem.  Once I've determined that, maybe it will be easy to fix.  If not, I'll ask for help on the maintainers list.

John W. Eaton <jwe>
Group administrator
Thu 03 Feb 2011 09:28:16 PM UTC, original submission:  

In 3.3.91 the following code


octave:1> plot(1:3, "-r;1;")
octave:2> hold on
octave:3> plot(2*(1:3), "-b;2;")

labels both curves as "2".

The code worked correctly in 3.3.54 and 3.2.4.

See also:

http://octave.1599824.n4.nabble.com/curve-key-in-3-3-91-td3258672.html

Dmitri.
p.s. There is no "3.3.91" tag in "Release field"...

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #22609:  demo_legend_18.pdf added by bpabbott (5KiB - application/pdf)
file #22608:  patch.legend added by dbateman (9KiB - application/octet-stream)
file #22607:  diffs.txt added by jwe (1KiB - text/plain)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by dbateman (Updated the item)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by bpabbott
  • -email is unavailable- added by jwe
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-02-06 bpabbott Attached File- Added demo_legend_18.pdf, #22609
    2011-02-05 dbateman StatusIn Progress Fixed
        Assigned toNone dbateman
        Open/ClosedOpen Closed
    2011-02-04 dbateman Dependencies- Depends on bugs #32022
    2011-02-04 dbateman Attached File- Added patch.legend, #22608
    2011-02-04 jwe Attached File- Added diffs.txt, #22607
    2011-02-04 bpabbott Carbon-Copy- Added -email is unavailable-
    2011-02-03 jwe Assigned tojwe None
        Carbon-Copy- Added bpabbott
    2011-02-03 jwe StatusNone In Progress
        Assigned toNone jwe

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code