bugGNU Octave - Bugs: bug #38323, printing image to svg uses same...


bug #38323: printing image to svg uses same embedded png filename with gnuplot 4.6

Submitted by:  None
Submitted on:  Wed 13 Feb 2013 09:06:46 AM UTC  
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  In Progress Assigned to:  None
Originator Name:  Daniel Kottke Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  dev
Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sun 03 Jul 2016 11:39:42 AM UTC, comment #20:

Retagging from "patch submitted" to "in progress", since Dan's latest patch differs from Mike's recommendation of using "failsafe".

Lachlan Andrew <lachlan>
Fri 01 Jul 2016 02:55:40 PM UTC, comment #19:

No, the fix in gnuplot is fairly recent and the change is listed in gnuplot's NEWS file as:

suggesting it will be in the next official release and I think the next release will be 5.1, but I'm not certain.

Dan Sebald <sebald>
Fri 01 Jul 2016 10:04:42 AM UTC, comment #18:

The current official gnuplot version is 5.0.3. And the mxe octave now builds gnuoplot 5.0.3.
Does this issue occur inn 5.0.3?

Tatsuro MATSUOKA <tmacchant>
Fri 27 May 2016 04:32:53 PM UTC, comment #17:

... Also, if the user decides that the images should be kept separate, Octave changes to that directory and then prints so there is no internal-link-reference confusion on part of the SVG file when viewing. ...

Dan Sebald <sebald>
Fri 27 May 2016 04:30:08 PM UTC, comment #16:

I'm attaching my recommended solution to this. It adds an 'svgstandalone' option. Also, if the user decides that the images should be kept separate. Put the following code in some .m file and rerun. Take note of the gnuplot behavior for creating the auxiliary file. I'm not quite happy with the way it does that. (It creates a new file every time...and then if one relaunches gnuplot, e.g., exits/restarts Octave the numbering starts from 1 again.) However, I don't think there is anything we can do--such as delete existing files--that would address gnuplot's internal workings.

(file #37290)

Dan Sebald <sebald>
Tue 24 May 2016 03:31:28 AM UTC, comment #15:

There has been a feature update to gnuplot development version. A version of SVG files with embedded PNG images can be obtained by using the terminal option "standalone". This is better approach than using "failsafe" in the plot command.

For quite some time there has been an option "standalone" for svg terminal in gnuplot, but it only applied to the mouse reference. For the development version the option 'standalone' also applies to image data. Without the standalone option, there will be external reference.

So, given the precedence of both gnuplot and Octave convention my suggestion is

1) Keep the Octave "svg" print device as it is, but place the referenced auxiliary PNG file in the same directory as the SVG image.

2) Introduce a new device "svgstandalone" that embeds the image within the SVG file. This is very consistent nomenclature with other devices.

Does that seem consistent with other device behavior?

Dan Sebald <sebald>
Thu 12 May 2016 08:21:42 PM UTC, comment #14:

Ok, thanks, so you have answered my question, we have to use the keyword "failsafe" for older versions of gnuplot.

Where the png file is written is irrelevant, Octave users expect the output of print to be a single svg file, not a pair of files that need to be copied around. And printing more than once produces different svg files that reference the same png file name. This is a completely non-usable feature.

If you want to work with gnuplot to introduce a new option for a future version of gnuplot, please do so, but Octave still needs a patch to produce a single svg file with the "failsafe" keyword with gnuplot 4.6.

Mike Miller <mtmiller>
Project Administrator
Thu 12 May 2016 08:03:47 PM UTC, comment #13:

I'm thinking a new option for gnuplot. One that can, if possible, make the default a standalone SVG file; then have an option that splits out PNG. I would prefer to not even introduce the term "failsafe" to the Octave scripts.

If there were a way to make Octave place that split-PNG file in the same directory as the SVG destination, that would be an incremental "bug fix".

I'll follow up with more on the possible gnuplot SVG term option.

Dan Sebald <sebald>
Thu 12 May 2016 07:48:40 PM UTC, comment #12:

For clarity, are you talking about a new option that would be in the svg terminal in gnuplot version 5.1 or 5.2? Or are you asking about an option that may have been in the svg terminal since gnuplot version 4.4 but we didn't know about it?

I'm asking because we will still need to support old gnuplot versions, so even if something is fixed in a future version, if we have to use "failsafe" in gnuplot 4 then we have to support that (yes, conditional on the svg terminal).

Mike Miller <mtmiller>
Project Administrator
Thu 12 May 2016 07:21:29 PM UTC, comment #11:

The answer in the gnuplot bug report is pretty much in synch with observations here. I'm not crazy about that solution of "failsafe" though. I'd say to condition its inclusion on "svg" because it might cause suboptimal behavior on other gnuplot terminals (e.g., postscript where instead of an image one will get individual pixels).

I'm going to inquire at that bug report if we can instead add a gnuplot option to the SVG terminal that will keep all data within the single file. (I think there is somewhere in the Octave gnuplot scripts where options for individual terminals is handled so it would be an easy change there.)

Dan Sebald <sebald>
Thu 12 May 2016 05:21:30 PM UTC, comment #10:

I'm adding Daniel Sebald to the CC list since he knows a lot about gnuplot and might be able to say whether the change in comment #9 is acceptable. Is the 'failsafe' keyword available in all versions of gnuplot, or only in modern ones? It might require modifying the _gnuplot_has_feature_.m script.

Rik <rik5>
Project Administrator
Thu 12 May 2016 03:28:27 AM UTC, comment #9:

As shown in this gnuplot bug report:


I made the following change in Octave:

In short, adding the keyword "failsafe" to the "with image" command.

This created a much larger svg file without the embedded png file. The svg image loads fine in eog and firefox.

No idea if this change is safe for all terminals or if logic needs to be added to apply it only to the svg terminal.

Mike Miller <mtmiller>
Project Administrator
Sun 28 Feb 2016 04:16:13 PM UTC, comment #8:

Still present (2/28/16). This is with gnuplot 5.0

Rik <rik5>
Project Administrator
Wed 13 Feb 2013 05:53:07 PM UTC, comment #7:

I can reproduce OPs problem with gnuplot 4.6. Works fine with gnuplot 4.4 because there is no png file. Apparently this is a new feature that makes the svg file smaller by embedding an external png.

A similar problem with this approach is if you print two or more different images to svg, the embedded png file will always have the same filename, gp_image_01.png, overwriting any previous plot saves.

This seems to me like unexpected, unscalable, and backwards-incompatible behavior. I'd be in favor of bypassing this feature of gnuplot if at all possible.

Regarding fltk, is this not already reported as bug #37753? Let's keep this one strictly about this gnuplot problem.

Mike Miller <mtmiller>
Project Administrator
Wed 13 Feb 2013 03:20:25 PM UTC, comment #6:

Ah, you're using gnuplot. I'm not. That's why the image is named "gp_"

I'm retitling this bug to reflect the actual problem.

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Wed 13 Feb 2013 03:00:50 PM UTC, comment #5:

It is always named: 'gp_image_01.png' and its in the current octave directory. So in the folder you started octave.

Wed 13 Feb 2013 02:56:44 PM UTC, comment #4:

I don't see a png image at all. What is the name, where are you seeing it?

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Wed 13 Feb 2013 02:55:09 PM UTC, comment #3:

No, it does include the image (it creates a png-file in your working directory and includes it as embedded-png in the svg file. if your svg is in your working directory, it should work). I found out that a problem is, that octave always uses the same name for the underlaying png. This is why, all your background images look the same in every svg-file, if you do many plots for different situations (that is the real bug of this thread).

To relate to original post: The problem with plotting in a different folder is due to the backgound-png, that is put into the working directory.

Wed 13 Feb 2013 02:38:37 PM UTC, comment #2:

As far as I can tell, the subdirectory thing is absolutely irrelevant. The issue is that the svg plot doesn't include the image, only the points in the plot. Can you confirm?

Jordi Gutiérrez Hermoso <jordigh>
Project Administrator
Wed 13 Feb 2013 09:25:38 AM UTC, comment #1:

I just found out, that that the reason is a png-file that lies under the svg. This is put into the working folder, and overwriten erverytime, you create a new svg.

I would be good, to name this png like the original svg+suffix and to put it in the same folder.

Wed 13 Feb 2013 09:06:46 AM UTC, original submission:

Hello everyone,

when printing a plot created by imshow and plot, there are different results. When printing into a folder, the previously plotted image is missing and just the points show up. See code:



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

Attach Files:

Attached Files


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by tmacchant (Posted a comment)
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 13 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-03 lachlan StatusPatch Submitted => In Progress
    2016-05-27 sebald Attached File- => Added octave-gnuplot_svg-djs2016may27.patch, #37290
    2016-05-25 rik5 Carbon-CopyRemoved 72865 => -
    2016-05-12 rik5 Carbon-Copy- => Added sebald
    2016-05-12 mtmiller StatusConfirmed => Patch Submitted
    2015-06-04 mtmiller Item GroupInaccurate Result => Incorrect Result
        Release3.6.2 => dev
        Operating SystemGNU/Linux => Any
    2013-02-13 mtmiller CategoryPlotting => Plotting with gnuplot
        Summary embedded png in svg missing in fltk when printing; always same png filename with gnuplo => printing image to svg uses same embedded png filename with gnuplot 4.6
    2013-02-13 jordigh StatusNeed Info => Confirmed
        SummaryMissing image when printing in folder => embedded png in svg missing in fltk when printing; always same png filename with gnuplo
    2013-02-13 jordigh StatusNone => Need Info

    Back to the top

    Powered by Savane 3.3