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 Release: 
Operating System:  * Any Fixed Release:  9.3.0
Planned Release:  9.3.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 19 Feb 2025 07:35:31 PM UTC, comment #11: 

@Liang: Great, glad there was a solution.

Rik <rik5>
Group administrator
Wed 19 Feb 2025 07:09:26 PM UTC, comment #10: 

@Rik, this is my fault.  Sorry to cause the trouble. 

There is a difference that I did not notice.  The startup folders/directories of gui and cli are different.  For issue in https://savannah.gnu.org/bugs/?66735, I have a bypass that happens to locate at the folder that gui defaults due to my previous session.  So the legend did not show in my environment due to the bypass. 

Please ignore my previous comments.  Thanks.

Liang Tang <lt1234>
Wed 19 Feb 2025 06:13:56 PM UTC, comment #9: 

I tried only one item in 9.4.0 before I stopped.  Again, I have not altered the startup.  No package is installed/loaded, no java, etc.  This is the one I tried: 

One-line input with Octave shipped cli shortcut (NO -f): C:\Octave\Octave-9.4.0\octave-launch.exe --no-gui

The legend shows up in the hgload plot for cli. 

I re-do the same in 9.4.0 gui, the legend is still missing. 

Thanks. 


Liang Tang <lt1234>
Wed 19 Feb 2025 05:35:26 PM UTC, comment #8: 

A bit of a long shot, were you running the Octave GUI or starting with '--no-gui' option for CLI?  Try the CLI just to make sure there isn't a race condition.

Also, try starting octave with '-f' option so that no system or user initialization files are read.  Just in case there is something odd in one of those files.

Third, I see that the commands are all on one line which has some implications for how the interpreter processes them.  Could you try typing the commands one-by-one into Octave (not in a file, nor cut&paste of the entire block).


fig=figure;
plot([0 1 ], [0 1]);
legend({'A'});
hgsave(fig, 'fig');
path(path);

 


Rik <rik5>
Group administrator
Wed 19 Feb 2025 04:09:40 PM UTC, comment #7: 

I just downloaded and installed 9.4.0 on win64. Nothing altered, including startup.  I am still getting the same result, i.e., the legend is missing in ofig load.  Pls see the attached jpeg for version, commands and results. Thanks.


Liang Tang <lt1234>
Wed 19 Feb 2025 03:01:29 PM UTC, comment #6: 


comment #5:

> I might have a slightly different observation.  The legend loaded back from ofig is completely missing. I am using 9.2.0. 


The fix was made for the 9.3 release of Octave.  Please upgrade to the latest stable release which is 9.4.  I verified your code runs properly there.

Rik <rik5>
Group administrator
Wed 19 Feb 2025 01:45:21 PM UTC, comment #5: 

I might have a slightly different observation.  The legend loaded back from ofig is completely missing. I am using 9.2.0. 

fig=figure; plot([0 1 ], [0 1]); legend({'A'}); hgsave(fig, 'fig'); path(path); hgload('fig.ofig')

Pls see the attached jpeg. 









Liang Tang <lt1234>
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 #56922:  legend_ofig_940.JPG added by lt1234 (60KiB - image/jpeg)
file #56921:  legend_ofig.JPG added by lt1234 (33KiB - image/jpeg)
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 lt1234 (Updated the item)
  • -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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-02-19 lt1234 Attached File- Added legend_ofig_940.JPG, #56922
    2025-02-19 lt1234 Attached File- Added legend_ofig.JPG, #56921
    2024-11-26 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 9.3.0
        Planned ReleaseNone 9.3.0
    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.15-ef91.
    Corresponding source code