bugGNU Octave - Bugs: bug #46435, rotated graphics output for device...

 
 

bug #46435: rotated graphics output for device pdfwrite

Submitter:  Andreas Stahel <sha1>
Submitted:  Fri 13 Nov 2015 03:38:36 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Andreas Stahel Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 19 Nov 2015 04:22:52 PM UTC, comment #5: 

I pushed a fix to the stable branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/234589c84d4a).  This will be a part of the next 4.0.1 bug fix release.

Rik <rik5>
Group administrator
Fri 13 Nov 2015 06:37:20 PM UTC, comment #4: 


By default Ghostscript determines viewing page orientation based on the dominant text orientation on the page. Sometimes, when the page has text in several orientations or has no text at all, wrong orientation can be selected.


Ghostscript seems to use some majority function so that when "most" of the text is running in a certain direction it tries to orient the page in that direction.

I added the option that Mike suggested to the default options in _ghostscript_.m.  See the attached diffs.txt.  It seems to fix the issue but more testing, including regression testing, should be done.


(file #35449)

Rik <rik5>
Group administrator
Fri 13 Nov 2015 05:43:30 PM UTC, comment #3: 

Good catch. I think this is due to the "AutoRotatePages" feature of ghostscript. The default value invokes some magic algorithm to rotate each page. If I use ps2pdf, I get the rotated output. If I add "-dAutoRotatePages=/None", it's upright.

Mike Miller <mtmiller>
Group Member
Fri 13 Nov 2015 05:11:50 PM UTC, comment #2: 

Confirmed as well with the gnuplot toolkit.  This suggests that the problem is general, and possibly in print.m, rather than in the C++ code dealing with gl2ps.

Also, Octave creates just eps or ps files, and if necessary converts those to a different format such as pdf, png, jpg, etc.  It appears that the intermediate ps file is correct, and that it might be the downstream tool which is introducing the bug.

For example,

plot (1:10);
ylabel (repmat ("a", 1, 15));
print ("x.ps");
## In shell, use a Postscript viewer to look at x.ps
## It was correct for me.
## Still in the shell, execute 'ps2pdf x.ps'
## Look at the file x.pdf.  It has been rotated relative to the input x.ps.



Rik <rik5>
Group administrator
Fri 13 Nov 2015 04:37:15 PM UTC, comment #1: 

Confirmed. With gl2ps and pdf output, the figure is rotated on the page if the string length of the ylabel exceeds the length of the xlabel by 15 or more characters.

A couple of simpler examples:


plot (1:10); ylabel (repmat ("a", 1, 15)); print ("x.pdf");
plot (1:10); xlabel (repmat ("a", 1, 10)); ylabel (repmat ("a", 1, 25)); print ("x.pdf");


Mike Miller <mtmiller>
Group Member
Fri 13 Nov 2015 03:38:36 PM UTC, original submission:  

Dear developer with version 4.0.0 and the current development release the code below generates a rotated PDF file. Some other plots are treated correctly. Using the device epsc and then epstopdf also generates the correct result.


x = linspace(-2,3);
plot(x,cosh(x),x,2*cos(x))
xlabel('-2<x<+3'); ylabel('Graphs of cosh(x) and 2*cos(x)');
grid on
text(-1, 0,'Hello')
print -dpdfwrite CoshCos.pdf
+verbatim+

Andreas Stahel <sha1>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #35449:  diffs.txt added by rik5 (641B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by sha1 (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-19 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2015-11-13 rik5 Attached File- Added diffs.txt, #35449
        StatusConfirmed Patch Submitted
    2015-11-13 rik5 CategoryPlotting with OpenGL Plotting
    2015-11-13 mtmiller CategoryPlotting Plotting with OpenGL
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code