bugGNU Octave - Bugs: bug #45285, printing with "-S..."...


bug #45285: printing with "-S..." option messes figure size and png output

Submitted by:  Juan Pablo Carbajal <juanpi>
Submitted on:  Tue 09 Jun 2015 05:50:07 PM UTC  
Category: Plotting with OpenGLSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: ConfirmedAssigned to: None
Originator Name: juanpiOpen/Closed: Open
Release: devOperating System: GNU/Linux

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 Jump to the original submission)

Thu 09 Nov 2017 10:40:26 PM UTC, comment #11:

Actually I spoke too soon, the workaround I provided is not equivalent to the "-S" option so it can't be used as a replacement for the current implementation.
The "-S" options changes the size of the figure while the workaround mainly changes the aspect ratio and the resolution (for raster formats only).

Pantxo Diribarne <pantxo>
Project Member
Thu 09 Nov 2017 06:04:19 AM UTC, comment #10:

We don't need to support this option for Matlab compatibility, but would it be nice to keep it for quickly specifying the output size? I understand that the equivalent scaling can be had by changing the paperposition property, but why can't Octave just do that for the user by specifying this single argument to print?

Rik <rik5>
Project Administrator
Wed 08 Nov 2017 04:49:09 PM UTC, comment #9:

@juanpi: I'd like to deprecate the "-S" option:

  • It is easy to do the same job with the "paperposition" property and this technique avoids having to scale figures at very large size.
  • Matlab does not have it so there is no compatibility problem

Do you have any objection.

Pantxo Diribarne <pantxo>
Project Member
Thu 29 Dec 2016 09:22:32 PM UTC, comment #8:

This issue is still present in Octave 4.2.0.

Running the sample code from comment #0 still produces one uncropped and two cropped png images on my Ubuntu PC.

Hartmut <hardy>
Wed 10 Jun 2015 10:09:12 PM UTC, comment #7:

Thanks Juan Pablo, with these additional informations I can trigger the bug using very large figure size, e.g.

Not only even the first figures file is incorrect, but the figure window itself ends maximized.

Retitling again.

Pantxo Diribarne <pantxo>
Project Member
Wed 10 Jun 2015 07:05:22 PM UTC, comment #6:


I tried all possible combinations of pause and drawnow and the error appears all the time.

Indeed fltk and gnuplot do not show the issue.

The for loop is not needed. The script is not even needed. Once a plot is printed with a different resolution the followings are not correct. Calling clf doesn't solve the problem, one needs to close the figure and create a new one.

Printing to sizes smaller than the screen size doesn't trigger the problem.

Juan Pablo Carbajal <juanpi>
Project Member
Wed 10 Jun 2015 01:06:01 PM UTC, comment #5:

@Juan Pi: the fact that it works offscreen (and I guess it also works with fltk) tells us that it is probably a threading issue like most of the problems we currently have with printing.

  • Can you try to move the pause before/after plot, and do the same with a "drawnow ()"?
  • Can you test if the for loop is needed, e.g run the following from a script (copy/paste in the command window may not trigger the bug):
  • The bug is probably triggered by the fact that you change the dpi. Can you check using the default resolution (without -S... option).
Pantxo Diribarne <pantxo>
Project Member
Wed 10 Jun 2015 11:13:56 AM UTC, comment #4:

Let me add that I am running Ubuntu 15.04 with nvidia driver 340.76

Juan Pablo Carbajal <juanpi>
Project Member
Wed 10 Jun 2015 11:09:25 AM UTC, comment #3:


The extra pause doesn't solve the issue.

I am sorry to have misunderstood "off-screen", I thought it meant "to disk" or "to file". Anyways, if I run the modified code

I get the right plots. If the image is visible I do not get the rigght plot, even if I add a pause. It seems that the screen doesn't resize after the s800,600 command.

Juan Pablo Carbajal <juanpi>
Project Member
Wed 10 Jun 2015 11:04:32 AM UTC, comment #2:

I also couldn't reproduce this behavior using MXE-Octave on Win7.

Avinoam Kalma <avinoam>
Project Member
Wed 10 Jun 2015 10:24:29 AM UTC, comment #1:


I can't reproduce this behavior using a self compiled Octave 4.0 on linux mint 17.1: all 3 png are identical and conform to what I expect. There may be a timing issue that is raised depending on the graphics capabilities of your hardware.

Can you add add a "pause (1)" after the "print" statement and report back?

BTW why did you mention "off screen" plots in the title? We have been using this terminology when printing invisible figures ("visible" = "off").

Pantxo Diribarne <pantxo>
Project Member
Tue 09 Jun 2015 05:50:07 PM UTC, original submission:

The following code

Produces a first png figure that is correct but all sequential figures are trimmed. See attached figures

Juan Pablo Carbajal <juanpi>
Project Member


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

Attach File(s):

Attached Files
file #34188:  qt_offscreen_fail.zip added by juanpi (53KiB - application/zip)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by avinoam (Posted a comment)
  • -unavailable- added by pantxo (Posted a comment)
  • -unavailable- added by juanpi (Submitted the item)

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

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 30 Dec 2016 12:21:50 AM UTCrik5Release4.0.0=>dev
    Fri 26 Jun 2015 08:35:10 PM UTCrik5StatusWorks For Me=>Confirmed
    Wed 10 Jun 2015 10:09:12 PM UTCpantxoCategoryPlotting=>Plotting with OpenGL
      SummaryPrinting qt figures from a for loop produces faulty files=>printing with "-S..." option messes figure size and png output
    Wed 10 Jun 2015 01:06:01 PM UTCpantxoSummarygraphics_toolkit qt wrong off screen plot=>Printing qt figures from a for loop produces faulty files
    Wed 10 Jun 2015 10:24:29 AM UTCpantxoStatusNone=>Works For Me
    Tue 09 Jun 2015 05:50:08 PM UTCjuanpiAttached File-=>Added qt_offscreen_fail.zip, #34188

    Back to the top

    Powered by Savane 3.1-cleanup1