bugGNU Octave - Bugs: bug #54924, savefig should accept a vector of...


bug #54924: savefig should accept a vector of figure handles for Matlab compatibility

Submitter:  Rik <rik5>
Submitted:  Tue 30 Oct 2018 09:51:56 PM UTC
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  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

Thu 01 Nov 2018 03:36:45 PM UTC, comment #7: 

I think we can leave things alone for now.  The basic functionality of saving and loading figures has been added to Octave, and I think we can wait to see if there are bug reports or requests for further features.

Rik <rik5>
Group administrator
Thu 01 Nov 2018 10:44:51 AM UTC, comment #6: 

Thanks Rik - you could have pushed the patch under your name as you did put a lot more work into this than I did!

Concerning the "compact" argument, your changes makes sense. I wonder if we could accept other format types (-v6, -v7, -hdf5) given they would work with hgsave.m.

    if (nargin == 3)
      fmt = varargin{3};
      if (strcmpi (fmt, "compact"))
        fmt = "-zip";

with the validation taking place in save.m.

Checking with matlab when the "compact" argument is used, the fig file contains a variable named hgS_080000 so we should also change hgload.m to reflect this:

hgs = {"s_oct40", "hgS_050200", "hgS_070000", "hgS_080000"};

Guillaume <gyom>
Wed 31 Oct 2018 07:50:18 PM UTC, comment #5: 

I implemented the "compact" argument in this cset: https://hg.savannah.gnu.org/hgweb/octave/rev/940aabcd6fdb.  Results will vary based on how well gzip can compress the data, but on a figure that had a sombrero() in it, file size went from 80KB to 17KB or ~4X.

Rik <rik5>
Group administrator
Wed 31 Oct 2018 07:13:19 PM UTC, comment #4: 

It turned out to be a fairly large changeset.  I took your patch and also modified the documentation and the BIST tests to check the new behavior.  See https://hg.savannah.gnu.org/hgweb/octave/rev/0ab70de0348e.

Closing report.

Rik <rik5>
Group administrator
Wed 31 Oct 2018 10:02:19 AM UTC, comment #3: 

And the BIST in hgsave testing for a single graphics handle should now be accepted as a valid syntax.

I also notice that the file format can be specified as a third argument to hgsave (with default -binary) but that it cannot be modified from the higher level function savefig. Should we reuse savefig's third input argument (currently present for matlab compatibility only) for that?

Guillaume <gyom>
Wed 31 Oct 2018 09:45:35 AM UTC, comment #2: 

True, I guess I thought it was a very unusual thing to do. I attach simple changes to hgload/hgsave that should make it possible now.

(file #45335)

Guillaume <gyom>
Tue 30 Oct 2018 10:20:34 PM UTC, comment #1: 

As currently implemented, savefig.m just calls hgsave.  Hence, the capability for multiple handles really needs to be added to hgsave/hgload.

Rik <rik5>
Group administrator
Tue 30 Oct 2018 09:51:56 PM UTC, original submission:  

According to the documentation for savefig, it should be able to save multiple figure windows in the same file.  It's not really a big deal, but if we could be compatible it would be nice.

Sample code:

h(1) = figure;
h(2) = figure;
savefig (h, "two_figs.ofig")

Rik <rik5>
Group administrator


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

Attach Files:

Attached Files
file #45335:  multiplehandles.patch added by gyom (2KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by gyom (Updated the item)
  • -email is unavailable- added by rik5 (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-10-31 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-10-31 gyom Attached File- Added multiplehandles.patch, #45335
    2018-10-31 rik5 Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code