bugGNU Octave - Bugs: bug #37913, subplot with copyobj inconsistent

 
 

bug #37913: subplot with copyobj inconsistent

Submitter:  Muhali <muhali>
Submitted:  Thu 13 Dec 2012 11:05:17 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  bpabbott
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 17 Dec 2012 12:16:48 AM UTC, comment #9: 
Ben Abbott <bpabbott>
Group Member
Mon 17 Dec 2012 12:08:43 AM UTC, comment #8: 

No objection. Thanks

Pantxo Diribarne <pantxo>
Group Member
Sun 16 Dec 2012 11:39:40 PM UTC, comment #7: 

I'm attached a changeset and a modified version of Pantxo's hdlcmp.m function.  I've added a demo script to hdlcmp.m.

With the attached changeset, the resulting copies created using copyobj() essentially identical.  The only difference is with the tick label positions where are off by less than eps().

Any objection to push?

(file #27109, file #27110)

Ben Abbott <bpabbott>
Group Member
Sat 15 Dec 2012 04:45:47 PM UTC, comment #6: 

I can confirm that listeners are triggered only if the value is changed regardless of the graphics_toolkit:


close all
graphics_toolkit gnuplot
ax = axes ();
markchanged = @(h, foobar, name) set (h, "userdata", [get(h,"userdata"); {name}]);
addlistener (ax, "position", {markchanged, "position"})
set (ax, "position", get (ax, "position"))
set (ax, "position", get (ax, "position").*.5)
res1 = get (ax, "userdata");
close all
graphics_toolkit fltk
ax = axes ();
addlistener (ax, "position", {markchanged, "position"})
set (ax, "position", get (ax, "position"))
set (ax, "position", get (ax, "position").*.5)
res2 = get (ax, "userdata");
assert (res1, res2)




Pantxo Diribarne <pantxo>
Group Member
Sat 15 Dec 2012 04:11:05 PM UTC, comment #5: 

Pantxo, my understanding is that the listeners are only triggered if the value of the property is changed.  Thus, the command below should not trigger a listener for the "position" property.


set (gca (), "position", get (gca (), "position"))


If it does, then something unintended is happening.

For the gnuplot graphics toolkit, the tick values of 0.6 are off by 0.5 eps ().  Looks like there is a small numeric problem somewhere.

I added the demo below to your hdlcmp.m to see the size of the difference in the property values.


%!demo
%! close all
%! ax1 = subplot (1, 1, 1);
%! ax2 = copyobj (ax1, gcf);
%! valdiff = hdlcmp (ax1, ax2).valdiff;
%! fields = fieldnames (valdiff{1,1});
%! for f = 1:numel(fields)
%!   dp = valdiff{1,1}.(fields{f}) - valdiff{1,2}.(fields{f});
%!   fprintf ("%s difference norm = %s\n", fields{f}, num2str (norm (dp)))
%! endfor


Regarding the fltk graphics toolkit, the problem may be independent of copyobj().  Perhaps Konstas will have some insight into this.  I've cc'd him.

Ben Abbott <bpabbott>
Group Member
Sat 15 Dec 2012 01:57:00 PM UTC, comment #4: 

I have added a listener to position and ztick properties to see how much times they are modified after the axes has been created.

diff -r 06832c90ae7d scripts/plot/struct2hdl.m
--- a/scripts/plot/struct2hdl.m        Fri Dec 14 16:03:50 2012 -0800
+++ b/scripts/plot/struct2hdl.m        Sat Dec 15 14:34:56 2012 +0100
@@ -172,7 +172,10 @@
       endif
     endfor
     h = axes (propval{:}, "parent", par);
-
+    disp ("add listener to position and ztick property")
+    markchanged = @(h, foobar, name) set (h, "userdata", [get(h,"userdata"); {name}]);
+    addlistener (h, "position", {markchanged, "position"})
+    addlistener (h, "ztick", {markchanged, "ztick"})
     if (isfield (s.properties, "__plotyy_axes__"))
       plty = s.properties.__plotyy_axes__;
       addproperty ("__plotyy_axes__", h, "any");



If I run the example below I can see that in gnuplot ztick is modified once, as expected, but position is never modified. In fltk ztick is also modifed once but position is modifed 15 times.


close all
graphics_toolkit gnuplot;
ax1 = subplot (1, 1, 1);
ax2 = copyobj (ax1, gcf);
disp ("gnuplot")
nztick = length (find (strcmp (get (ax2, "userdata"), "ztick")))
npos = length (find (strcmp (get (ax2, "userdata"), "position")))
close all
graphics_toolkit fltk;
ax1 = subplot (1, 1, 1);
ax2 = copyobj (ax1, gcf);
disp ("fltk")
nztick = length (find (strcmp (get (ax2, "userdata"), "ztick")))
npos = length (find (strcmp (get (ax2, "userdata"), "position")))


Wild guess:  in gnuplot position is updated only if the requested value is different from the current one?


Pantxo Diribarne <pantxo>
Group Member
Sat 15 Dec 2012 01:13:38 PM UTC, comment #3: 

My tip is:

$ hg tip
changeset:   15793:06832c90ae7d
tag:         tip
user:        Rik <rik@octave.org>
date:        Fri Dec 14 16:03:50 2012 -0800
summary:     build: Include new gui icons in distribution tarball.


I use the attached hdlcmp.m to compare model and clone properties. The example below still shows me what I explained previously.


close all
graphics_toolkit gnuplot;
ax1 = subplot (1, 1, 1);
ax2 = copyobj (ax1, gcf);
valdiff = hdlcmp (ax1, ax2).valdiff
close all
graphics_toolkit fltk;
ax1 = subplot (1, 1, 1);
ax2 = copyobj (ax1, gcf);
valdiff = hdlcmp (ax1, ax2).valdiff


(file #27100)

Pantxo Diribarne <pantxo>
Group Member
Fri 14 Dec 2012 11:31:39 PM UTC, comment #2: 

My tip is;


$ hg tip
changeset:   15792:12394261da0f
tag:         tip
user:        Rik <rik@octave.org>
date:        Fri Dec 14 13:58:19 2012 -0800
summary:     doc: tweak docstrings for javaObject and javaArray.


The example works for me.  Was this bug fixed by the recent changesets to hdl2struct()?  For example, the one below.


changeset:   15775:a1d1386daeed
user:        Ben Abbott <bpabbott@mac.com>
date:        Wed Dec 12 18:07:55 2012 -0500
summary:     struct2hdl.m: Set the "*.mode" properties last.  (Bug # 37645)



Ben Abbott <bpabbott>
Group Member
Thu 13 Dec 2012 11:05:42 PM UTC, comment #1: 

I can confirm on linux mint. I have different behaviors for gnuplot and fltk :
 - gnuplot : "x(yz)tick" properties are slightly different. The axes look perfectly matched though.
 - fltk : same as gnuplot plus "tightinset" (read only) and "position" that are clearly different (and so does the axes look). If I force he position afterward, the axes seem to match but the tick labels don't.





Pantxo Diribarne <pantxo>
Group Member
Thu 13 Dec 2012 11:05:17 AM UTC, original submission:  

I one does


subplot(1, 1, 1)
h = copyobj(gca, gcf) ;


the two plots do not match.

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #27109:  changeset.patch added by bpabbott (1KiB - application/octet-stream)
file #27110:  hdlcmp.m added by bpabbott (3KiB - application/octet-stream)
file #27100:  hdlcmp.m added by pantxo (3KiB - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (If you have some time, would you take a look as this bug?)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by muhali (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 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-05-16 bpabbott StatusReady For Test Fixed
    2013-01-01 bpabbott Open/ClosedOpen Closed
    2012-12-17 bpabbott CategoryNone Plotting
        Item GroupNone Incorrect Result
        StatusPatch Submitted Ready For Test
        Assigned toNone bpabbott
    2012-12-16 bpabbott Attached File- Added changeset.patch, #27109
        Attached File- Added hdlcmp.m, #27110
        StatusWorks For Me Patch Submitted
        Operating SystemGNU/Linux Any
    2012-12-15 bpabbott Carbon-Copy- Added -email is unavailable-
    2012-12-15 pantxo Attached File- Added hdlcmp.m, #27100
    2012-12-15 bpabbott StatusConfirmed Works For Me
    2012-12-14 bpabbott StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code