bugGNU Octave - Bugs: bug #65315, Colorbar not saved appropriately...


bug #65315: Colorbar not saved appropriately with hgsave

Submitter:  Glenn Groeschel <glenn>
Submitted:  Wed 14 Feb 2024 05:38:39 PM UTC
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 8.4.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Tue 20 Feb 2024 10:05:10 PM UTC, comment #5: 

polar() has "rtick" and "ttick" properties, no "thetaticks" properties.  But you are correct that these are not being restored with hgload.  I can see that they are saved properly by hgsave.

Rik <rik5>
Group administrator
Tue 20 Feb 2024 07:20:56 PM UTC, comment #4: 

The properties rticks and thetaticks also disappear on polar plots that are saved and then re-opened.

Glenn Groeschel <glenn>
Fri 16 Feb 2024 12:43:01 AM UTC, comment #3: 

I pushed a second changeset that saves function callbacks like "buttondownfcn" or "deletefcn" in this changeset https://hg.savannah.gnu.org/hgweb/octave/rev/cd61d41dc913.  Because I can't guarantee this won't cause problems I put this on the development branch.

The remaining item, the correct saving/restoration of colorbars (and legends), is proving to be very tricky.  This might take some time.

Rik <rik5>
Group administrator
Thu 15 Feb 2024 06:12:03 PM UTC, comment #2: 

I pushed a fix for the first of these items (can't save colorbars when "tag" property is used) to the stable branch that will be released very soon as Octave 9.1.  See https://hg.savannah.gnu.org/hgweb/octave/rev/9cb993582499.

Rik <rik5>
Group administrator
Thu 15 Feb 2024 01:55:47 AM UTC, comment #1: 

Thanks for reporting.  I verified the first problem: a "tag" interferes with saving of colorbar.  I haven't checked the others, but changing Status to Confirmed.

Rik <rik5>
Group administrator
Wed 14 Feb 2024 05:38:39 PM UTC, original submission:  

Great software, it is incredible what Octave has grown into.
Three related (I think) bugs to colorbars:
1. When an axis with a 'tag' property is saved using hgsave and it has a colorbar, the colorbar is not recreated when using hgload.

2. When an axis with a colorbar is saved with hgsave and reopened with hgload, changes to the colormap and color axis limits are updated on the main axis but not on the colorbar axis.

3. Any callbacks aren't saved using hgsave

I would expect a figure opened with hgload would be identical to when it was saved both visually and functionally (including buttondown callbacks).

I think all three issues are related to the hgsave function and how it parses the existing figure, which I why I grouped the three items together.

I'm using Windows 10, 22H2
Octave v8.4.0,"x86_64-w64-mingw32"

Code reproducing issues below.

%Minimum working example to demonstrating
% 1. The colorbar is not saved using hgsave if the main axis uses the 'tag' property
% 2. When opening a saved figure with a colorbar the colorbar is no longer linked to
%    the main axis when using caxis or colormap functions
% 3. Callbacks aren't saved using hgsave, so when figures are reopened they do not
%    function the same as the original figure

set(hax,'tag','sombrero');  %Tag to find axis easily later
colormap(hax,'jet'); %Both plot and color bar adjust appropriately on new figure

%open saved figure
hfig2=hgload('color_bar_test.ofig'); %New figure opens, missing colorbar

%If we do everything the same but don't use tag property colorbar is saved
%set(hax3,'tag','sombrero');  %Tag to find axis easily later
set(hax3,'buttondownfcn', @(h, e) disp ("Button Down Callback"));
colormap(hax3,'jet'); %Both plot and color bar adjust appropriately on new figure
caxis(hax3,[-4,4]);  %Axis limits and legend update, :)
%Clicking on the axis of figure3 display 'Button Down Callback'

%open saved figure
hfig4=hgload('color_bar_test_notag.ofig'); %New figure opens, with colorbar
%Try to change caxis limits
hax4=findobj(hfig4,'type','axes','xlimmode','auto');  %Color bar has manual xlimmode, use this to find sombrero axis
colormap(hax4,'winter'); %Colorbar does not update, no longer linked :(
caxis(hax4,[-1,1]); %Axis limits also not linked anymore :(
%Clicking on axis of figure4, no callback is fired or even exists
missing=get(hax4,'buttondownfcn');  %Callback is empty, not saved :(

Glenn Groeschel <glenn>


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

Attach Files:

Attached Files
file #55701:  color_bar_test.m added by glenn (2KiB - text/plain - Octave file demonstrating perceived bugs)


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 glenn (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-02-15 rik5 StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
    2024-02-14 glenn Attached File- Added color_bar_test.m, #55701

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code