bugGNU Octave - Bugs: bug #65904, copyobj figure missing legend...

 
 

bug #65904: copyobj figure missing legend markers

Submitter:  Al Cabato <acoustics>
Submitted:  Fri 21 Jun 2024 07:59:02 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 9.2.0 Operating System:  * Any
Fixed Release:  9.3.0 (current stable) Planned Release:  9.3.0 (current stable)
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 26 Nov 2024 12:48:25 AM UTC, comment #4: 

I applied a more minimal changeset (https://hg.savannah.gnu.org/hgweb/octave/rev/a25b50b9034c) which fixes the issue for the two examples in this report.  This will be a part of the 9.3 release which should be quite soon.

Marking as Fixed and closing report.

Rik <rik5>
Group administrator
Sat 06 Jul 2024 07:47:42 AM UTC, comment #3: 

Thanks for the patch! This patch also fixed a bug in Octave version 9.2.0 that the markers in the legend of a figure were not restored after saving the figure to disk, then after opening the figure from disk, the markers were missing!

My 'minimal working example' that I was about to post was:

% Minimal Working Example, Save & Load figure has missing markers in the legend
close all; clear all
figure(1)
ph=plot([1 2],[1 1],'-',[1 2],[2 2],'x',[1 2],[3 3],'+',[1 2],[4 4],'.')
xlim([0 3])
ylim([0 5])

objh = legend({'line','cross x','plus +','dot .'})

% Save the figure to disk
savefig('missingmarkers.ofig')

% Open the figure that was just saved, but the markers in the legend are missing!
openfig('missingmarkers.ofig')

If one were to inspect the Figures 1 and 2 from a non-patched version of Octave 9.2.0, one would see that in Figure 1 the markers are shown in the legend, but in Figure 2, after issuing the openfig(...) command, the markers are missing. This patch fixed the issue. Thank you!

John <yingwee>
Thu 27 Jun 2024 04:03:30 PM UTC, comment #2: 

Legend markers are handled specially in legend.m and their handles are not visible.  They are simply found with the property markertruesize.

In hdl2struct.m, these need to be added to the regular child lists for the legend, and not marked as special.

These changes seem to work for me:


@@ -62,6 +62,8 @@ function s = hdl2struct (h)
         ## Check for polar plots with special "polar_grid" object
         ## FIXME: A hack to fix bug #62093.
         kids = [kids; findall(h, "tag", "polar_grid")];
+        ## Add legend markers which are normally hidden
+        kids = [kids; findall(h, '-depth', 1, 'type', 'line', '-property', 'markertruesize')];
       endif

       nkids = length (kids);
@@ -131,6 +133,10 @@ function hlist = getspecial (h)
   hlist = [];

   regkids = get (h, "children");
+  ## Add legend markers which are normally hidden to regkids
+  if ( strcmp (get (h, "tag"), 'legend') )
+    regkids = [regkids; findall(h, 'type', 'line', '-property', 'markertruesize')];
+  endif
   ## inline version of allchild() for performance
   set (0, "showhiddenhandles", "on");
   allkids = get (h, "children");


Al Cabato <acoustics>
Sat 22 Jun 2024 05:45:56 PM UTC, comment #1: 

Copying legends with markers used to work with Octave the version that was used the last time the sourceforge doc was generated.

I tested with Octave 6 (the oldest version I have at hand) and the regression seems to have happened before that, probably when the legend code was entirely rewritten.

The simplest way to reproduce is to run `demo copyobj 1`


Pantxo Diribarne <pantxo>
Group Member
Fri 21 Jun 2024 07:59:02 PM UTC, original submission:  

The legend is incorrect when using copyobj to copy a figure.  The legend in the new figure is missing markers.

Test using Demonstration 1 in the Octave Forge documentation.


Al Cabato <acoustics>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #56181:  copyobj.png added by acoustics (47KiB - image/png - copyobj figure missing legend markers)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by yingwee (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by acoustics (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-11-26 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 9.3.0 (current stable)
        Planned ReleaseNone 9.3.0 (current stable)
    2024-06-22 pantxo CategoryOctave Function Plotting with OpenGL
        Item GroupIncorrect Result Regression
        StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
    2024-06-21 acoustics Attached File- Added copyobj.png, #56181

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code