bugGNU Octave - Bugs: bug #64510, support saving plots to files...

 
 

bug #64510: support saving plots to files without a file extension

Submitter:  Janez Žemva <janezz55>
Submitted:  Thu 03 Aug 2023 12:05:48 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  3 - Low Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Janez Žemva Open/Closed:  * Closed
Release:  * 8.2.0 Operating System:  * Any
Fixed Release:  9.1.0 Planned Release:  9.1.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 07 Sep 2023 06:32:49 PM UTC, comment #10: 

I checked that saving to a file with no extension does work with the new option. Closing report as fixed.

Pantxo Diribarne <pantxo>
Group Member
Wed 30 Aug 2023 05:17:13 PM UTC, comment #9: 

The new test was failing on the MINGW CI because that is running with `--no-gui-libs`. Attempting to print an invisible figure seems to fail with the fltk graphics toolkit:

>>>>> processing D:\a\octave\octave\scripts\plot\util\print.m
***** test
 hf = figure ("visible", "off");
 unwind_protect
   x = 0:0.1:1;
   hax = axes (hf);
   plot (hax, x, x);
   tmp_name = tempname ();
   print (hf, tmp_name, "-dpng");
   assert (isfile ([tmp_name ".png"]));
   unlink ([tmp_name ".png"]);
   print (hf, tmp_name, "-dpng", "-no-append-file-extension");
   assert (isfile (tmp_name));
   unlink (tmp_name);
 unwind_protect_cleanup
   close (hf);
 end_unwind_protect
!!!!! test failed
print: rendering with fltk toolkit requires visible figure (DISPLAY='')


Should be fixed here:
https://hg.savannah.gnu.org/hgweb/octave/rev/774c54278e97

Markus Mützel <mmuetzel>
Group administrator
Wed 30 Aug 2023 03:05:59 PM UTC, comment #8: 

Oops. That broke building the documentation.
Hopefully fixed here:
https://hg.savannah.gnu.org/hgweb/octave/rev/d2540b8c9fdd

Markus Mützel <mmuetzel>
Group administrator
Wed 30 Aug 2023 02:41:02 PM UTC, comment #7: 

I pushed the patch to the default branch here:
https://hg.savannah.gnu.org/hgweb/octave/rev/d668c52cf2e6

It should be part of Octave 9 when it will be released (probably some time early next year).

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Sun 27 Aug 2023 03:51:53 PM UTC, comment #6: 

wow, I am happy with the patch.

Janez Žemva <janezz55>
Sun 27 Aug 2023 02:50:39 PM UTC, comment #5: 

Oops. Forgot about that preference.

See the updated patch.

(file #55089)

Markus Mützel <mmuetzel>
Group administrator
Sun 27 Aug 2023 02:45:06 PM UTC, comment #4: 

I'd prefer that we not use underscores in option names like this but consistently use hyphens to separate words instead.

John W. Eaton <jwe>
Group administrator
Sun 27 Aug 2023 02:40:38 PM UTC, comment #3: 

Does the attached patch work for you?

I chose the flag "-no_append_file_extension" for this new feature. The long name and the underscores in the flag make it hopefully very unlikely that this will ever collide with a new flag in a future Matlab version.

I haven't tested extensively yet whether this works for all possible formats with all possible toolchains and combinations of flags. Only checked "-dpng" and "-dsvg" with default flags so far.


(file #55088)

Markus Mützel <mmuetzel>
Group administrator
Thu 03 Aug 2023 02:35:19 PM UTC, comment #2: 

I actually had the print() function in mind, as AFAIK, nothing prevents octave from extending matlab semantics with new functionality. As I explained previously, I had a new option in mind, say, "-noextappend", print would then be invoked as:

print(gcf, '/dev/stdout', '-dsvg', '-noextappend')

please refer to octave docs to see:

print (HFIG, ...)

this means an arbitrary number of arguments can be supplied to print(), including octave-specific arguments. Compatibility with Matlab would not be affected.

Janez Žemva <janezz55>
Thu 03 Aug 2023 02:20:50 PM UTC, comment #1: 

I'm guessing you are referring to the `saveas` function. Is that correct?

If you do, I don't know how that could be done without breaking compatibility with Matlab:
https://de.mathworks.com/help/matlab/ref/saveas.html

> saveas(fig,filename,formattype) creates the file using the specified file format, formattype. If you do not specify a file extension in the file name, for example, 'myplot', then the standard extension corresponding to the specified format automatically appends to the file name. If you specify a file extension, it does not have to match the format. saveas uses formattype for the format, but saves the file with the specified extension. Thus, the file extension might not match the actual format used.


Is there another function that you have in mind?

The same goes for the `print` function:
https://de.mathworks.com/help/matlab/ref/print.html

> print(filename,formattype) saves the current figure to a file using the specified file format, such as print('BarPlot','-dpng'). If the file name does not include an extension, then print appends the appropriate one.

Markus Mützel <mmuetzel>
Group administrator
Thu 03 Aug 2023 12:05:48 PM UTC, original submission:  

Due to some confusion I am rephrasing my previous bug report. Currently, it is not possible to save a plot to a file without an extension, octave will always append an extension to a file name, if an extension is not already provided. In other words, saving a plot to a file "plot" is not possible, but saving to "plot.svg", for example, is possible. Providing a fix for this issue would also fix: https://savannah.gnu.org/bugs/?64473 for me.

Janez Žemva <janezz55>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55089:  bug64510-print-no-file-extension-v2.patch added by mmuetzel (3KiB - application/octet-stream)
file #55088:  bug64510-print-no-file-extension.patch added by mmuetzel (3KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by janezz55 (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
    2023-09-07 pantxo StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2023-08-30 mmuetzel StatusPatch Submitted Ready For Test
        Fixed ReleaseNone 9.1.0
    2023-08-27 mmuetzel StatusNeed Info Patch Submitted
    2023-08-27 mmuetzel Attached File- Added bug64510-print-no-file-extension-v2.patch, #55089
    2023-08-27 mmuetzel Attached File- Added bug64510-print-no-file-extension.patch, #55088
        Priority5 - Normal 3 - Low
        Planned ReleaseNone 9.1.0
        Summaryoctave does not support saving plots to files without an extension support saving plots to files without a file extension
    2023-08-03 mmuetzel StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code