bugGNU Octave - Bugs: bug #46122, gnuplot printed figure truncated

 
 

bug #46122: gnuplot printed figure truncated

Submitter:  ederag <ederag>
Submitted:  Sun 04 Oct 2015 04:12:59 PM UTC
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  siko1056
Originator Name:  Ederag Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

( Jump to the original submission )

Fri 18 Dec 2015 08:50:27 PM UTC, comment #11: 

With the fix for 46292 pushed, I think this bug/problem is also fixed.

http://hg.savannah.gnu.org/hgweb/octave/rev/80dd7b3529ee

Ben Abbott <bpabbott>
Project Member
Wed 16 Dec 2015 07:09:17 PM UTC, comment #10: 

@Ederag,
My point on the axis units, is that it's size on the screen is not related to the size of the output produced by print() or saveas(). To produce a figure of a specified size and with a specified font for publication purposes, all that is needed is to specify the font size of all the objects and to specify the paperposition width and height.

width = 9;
height = 6;
paperunits = "centimeters";
fontsize = 10;
set (gcf (), "paperunits", paperunits)
set (gcf (), "paperposition", [0 0 width height])
h = findall (gcf (), "-property", "fontsize");
set (h, "fontsize", fontsize)
print -dpdfwrite figure.pdf

If you use -dpdf, then you also need to specify the paper size.

set (gcf (), "papersize", [width, height])

If you desire a wysiwyg solution, please refer to the two comments below on bug report 46292.

https://savannah.gnu.org/bugs/?46292#comment15
https://savannah.gnu.org/bugs/?46292#comment16

The script I provided works for the qt graphics toolkit. If you like I can try to work out one for gnuplot as well. The primary difference is that the figure size for gnuplot needs to be spedified when the figure is created.

Ben Abbott <bpabbott>
Project Member
Wed 16 Dec 2015 06:37:08 PM UTC, comment #9: 

Dear Ben, here is the rationale for setting "DefaultAxesUnits" to "centimeters".
I was preparing a figure for a paper, with several sub plots, a colorbar spanning the whole figure...
Since the figure width has to be fixed to the article width, and since I have a better feeling of the good sizes in centimeters,  it seemed sensible to control all positions in centimeters too.

Maybe "need" is a bit strong. Of course it would be possible to write a function converting (X, Y) positions from centimeters to normalized units. Less elegant, but working.

On the other hand, according to the documentation, using centimeters units should work.

One other very important point when preparing a complex figure, is that the size on screen should be the same as the final one in the article. Then it is much faster to arrive at the desired result.
This is why I insist to set the figure position also
(this is working fine if defaultfigureunits is set to centimeters beforehand).

ederag <ederag>
Tue 15 Dec 2015 09:33:05 PM UTC, comment #8: 

No, I need 'DefaultAxesUnits', 'centimeters'.
I'll try again tomorrow to explain why.

About paperorientation, matlab is pure non-sense about that,
and I was glad that octave did not comply.
But this is really another story.

ederag <ederag>
Tue 15 Dec 2015 09:16:51 PM UTC, comment #7: 

Ederag,

The figure "position" specifies the location the figure is placed on your monitor and has no effect when printing. The "defaultaxesunits" also do not impact printing.

Regarding the orientation, if you do not change the orientation, your example should work. Specifically, the example below works for me.

plot (rand (3))
set (gcf (), 'paperunits', 'centimeters')
set (gcf (), 'papersize', [21, 12])
set (gcf (), 'paperposition', [0 0 21, 12])
print -dpdf foo.pdf

There is a bug present, but it is not what you think. The bug is that changing the paperorientation modifies the value of the paperposition. This should not happen (according the Mathworks documentation and confirmed by testing).

Ben Abbott <bpabbott>
Project Member
Tue 15 Dec 2015 08:49:56 PM UTC, comment #6: 

Dear Ben, you missed the figure positioning and the 'DefaultAxesUnits', 'centimeters'.

These are need to control the figure in (approximated) wysiwyg mode. Please see the modified script attached.
Unfortunately, these trigger the truncated printout.

The orient stuff is not relevant here (or needed by the way).

(file #35755)

ederag <ederag>
Tue 15 Dec 2015 01:32:30 PM UTC, comment #5: 

This is a regression. When printing GL2PS requires (by design) that the figure be scaled such that there is 1 pixel for each point to be rendered. To avoid toolkit specific code in _print_parse_opts_.m and in print.m, the same convention is done for gnuplot.

As a result, this change results in an incorrect figure size. On my system, my screen resolution is 129 pixel/in, and this change reduces the intended size by 72/129. Thus, the standard 8x6 output is reduced to 4.4651x3.3488.

Thus, this changeset will need to be reverted.

@Ederag, I've looked over you m-file and have edited it to provide the behavior you desire. You can simpify this task and avoid worrying about the papersize and orientation by just specifying the paperposition and then using the -dpdfwrite terminal.

close all
plot (rand (3))
set (gcf (), 'PaperUnits', 'centimeters');
set (gcf (), 'PaperPosition', [0, 0, 21, 12]);
print -dpdfwrite try.pdf

Both my modified m-file and the simplified commands assume this change is reverted.

(file #35750)

Ben Abbott <bpabbott>
Project Member
Tue 06 Oct 2015 09:10:37 AM UTC, comment #4: 
Kai Torben Ohlhus <siko1056>
Project Member
Tue 06 Oct 2015 07:35:17 AM UTC, comment #3: 

Please use my address in the "To" field of this message.
Thank you !

ederag <ederag>
Tue 06 Oct 2015 07:19:44 AM UTC, comment #2: 

Thank you for you patch. Your changes look reasonable and I'll push them. How do you want to get mentioned as Author ederag? The pattern is

"John W. Eaton <jwe@octave.org>"

Kai Torben Ohlhus <siko1056>
Project Member
Sun 04 Oct 2015 08:21:51 PM UTC, comment #1: 

I tested your changes, they work for me.

As a sidenode, I think something went wrong with the format of your patch. It should probably not refer to a .orig file.

Stefan Miereis <stefanm>
Sun 04 Oct 2015 04:12:59 PM UTC, original submission:  

Trying to create a figure for an article, with custom size,
specified in centimeters, the screen output was really fine,
while the printed output was truncated.

The fix was to use the actual "ScreenPixelsPerInch" instead of 72
in _gnuplot_drawnow_.m.

Please find a patch attached,
as well as a small script to reproduce the bug.

ederag <ederag>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #35750:  script_wysiwyg_modified.m added by bpabbott (543B - application/octet-stream)
file #35058:  script_wysiwyg.m added by ederag (858B - text/x-matlab)
file #35059:  __gnuplot_drawnow__.m.patch added by ederag (715B - 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 bpabbott (Updated the item)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by stefanm (Posted a comment)
  • -email is unavailable- added by ederag (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 project members can vote.

     

     

     

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-15 ederag Attached File- Added script_wysiwyg_modified_fixpos_simpler.m, #35755
    2015-12-15 bpabbott Attached File- Added script_wysiwyg_modified.m, #35750
        Originator Name Ederag
    2015-10-06 siko1056 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2015-10-06 siko1056 Assigned toNone siko1056
    2015-10-05 mtmiller StatusNone Patch Submitted
    2015-10-04 ederag Attached File- Added script_wysiwyg.m, #35058
        Attached File- Added _gnuplot_drawnow_.m.patch, #35059

    Back to the top


    Powered by Savane 3.9