|
From: | Ben Abbott |
Subject: | Re: Plot to PDF |
Date: | Thu, 09 Jul 2009 21:27:12 -0400 |
On Jul 9, 2009, at 9:10 PM, Torquil Macdonald Sørensen wrote:
Ben Abbott wrote:On Jul 9, 2009, at 6:50 PM, Torquil Macdonald Sørensen wrote: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.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'musing the octave3.2 from Debian Sid. Thanks Torquil SørensenThe 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 tryset (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 BenThanks Ben, I will try to explain more thoroughly and provide some files. When using the plot command, a window appears, with certain dimensions. This window is a bit wider than it is tall. I would like the PDF to have the same dimensions.When I use the print command to obtain an EPS file, the EPS has the same aspect ratio as this window. When printing to PDF, there is lots of extra white space above and below the plot. So the result is not the same when printing to EPS and PDF. So printing to EPS gives the desired result.(Btw, I assume you meant "print test.pdf", not "plot plot.pdf" in your example code above)I have uploaded and EPS and a PDF so that the difference can be seen: * EPS example: plot (1:10) print plot.eps Result: http://folk.uio.no/tmac/plot.eps * PDF example: plot (1:10) print plot.pdf Result: http://folk.uio.no/tmac/plot.pdfThe EPS has the format that I want, and which is the same as the plot window displayed by octave after the plot command.The "set(gcf..." you included in the above has the following effect:EPS case: It affects the aspect ratio of the graphic, as well as the paper format/size.PDF case: It affects only the graphic, not the page format/size of the PDF file.Best regards Torquil Sørensen
Thanks for providing more detail. The behavior of Octave is consistent with Matlab and is intended. To obtain a pdf file that is the same size as the eps dpi = get (0, "screenpixelsperinch"); pos = get (gcf, "position"); papersize = pos(3:4)./dpi; set (gcf, "papersize", papersize) set (gcf, "paperposition", [0, 0, papersize]) plot(1:10) print test.pdfIf you compare the the eps file, be sure your viewer clips the result at the bounding box. Otherwise, you'll see an additional 50pt border.
Ben
[Prev in Thread] | Current Thread | [Next in Thread] |