Plot to PDF

Ben Abbott bpabbott at mac.com
Fri Jul 10 11:04:43 CDT 2009


On Friday, July 10, 2009, at 09:53AM, "Jonathan Stickel" <jjstickel at vcn.com> wrote:
>
>On 7/9/09 help-octave-request at octave.org wrote:
>> From: Ben Abbott <bpabbott at mac.com>
>> Subject: Re: Plot to PDF
>> To: Torquil Macdonald S?rensen <torquil at gmail.com>
>> Cc: help-octave at octave.org
>> Message-ID: <2B4F40B4-3607-4E58-BA11-DC32AF0BF060 at mac.com>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes
>> 
>> On Jul 9, 2009, at 6:50 PM, Torquil Macdonald S?rensen wrote:
>> 
>>> > Hi!
>>> >
>>> > When I plot to pdf in octave, the page format turns out wrong. The  
>>> > resulting PDF
>>> > looks like an A4 page, even though the actual plot is wider than its  
>>> > height
>>> > (standard format). I'm using octave 3.2 and the newest gnuplot  
>>> > development
>>> > snapshot. Plotting to PDF with gnuplot works fine using the pdfcairo  
>>> > terminal.
>>> >
>>> > The command I have tried when plotting to pdf in octave is:
>>> >
>>> > fplot(blablabla...)
>>> > print("plot.pdf")
>>> >
>>> > It works, apart from that page format issue. Anyone know how to do  
>>> > it right? I'm
>>> > using the octave3.2 from Debian Sid.
>>> >
>>> > Thanks
>>> > Torquil S?rensen
>> 
>> It's not clear to me what you are seeing, or what you expect to see.  
>> So I'll explain what should happen and you can comment.
>> 
>> Both pdf an postscript output respect the papersize and paperposition  
>> properties.
>> 
>> The default are
>> 
>> papersize = [8.5, 11];
>> paperposition = [0.25, 2.5, 8.0, 6.0];
>> 
>> The resulting pdf/postscript output should (approximately) fill a 8x6  
>> in box centered on a page of 8.5x11 inches.
>> 
>> If this is what you see, then all is working correctly.
>> 
>> If you'd like to produce a pdf to import into a LaTeX document (or a  
>> figure for a similar purpose), then try
>> 
>> set (gcf, "papersize", [6.4, 4.8])
>> set (gcf, "paperposition", [0, 0, 6.4, 4.8])
>> plot (1:10)
>> xlabel ("xlabel")
>> ylabel ("ylabel")
>> title ("title")
>> plot test.pdf
>> 
>> Ben
>
>This makes a nice looking plot, but it is in the lower left corner of an 
>8.5x11 in page!  It seems that the papersize is not being respected. 
>Interestingly, the fonts of the pdf output are nice and large.  However, 
>if I subsequently print to eps, the fonts are tiny in the eps output.
>
>Jonathan

Thanks for catching the papersize bug. This is due to ghostscript. Presently ghostscript is used to produce a pdf from a postscript output. The postscript is the proper size (per the bounding box) but the resulting pdf is letter size (or perhaps a4). The solution will be to explicitly tell ghostscript the size of the page by using the options ...

    -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h

Where w and h are in points.

Another solution is to run the developers version of gnuplot (version >= 4.3).

Regarding the eps fontsize, this is a gnuplot feature. I don't have a gnuplot manual handy, but I recall the decreased fontsize is documented. Perhaps we should use ghostscript to convert from ps to eps so that we obtain consistent fontsizes?

I'll add these to my list of things that need work. However, my computer is still out for repair and I'm very busy with selling my home, packing, and moving ... it might be a few weeks before I can get to this. So if anyone has the initiative, please dig in.

Ben







More information about the Help-octave mailing list