[R] Bounding box on plotting files inserted into a LaTeX document

Patrick Connolly p_conno||y @end|ng |rom @||ng@hot@co@nz
Fri May 17 09:57:17 CEST 2019


On Thu, 16-May-2019 at 07:52PM -0400, Marc Schwartz wrote:

|> 
|> 
|> > On May 16, 2019, at 7:04 PM, Patrick Connolly <p_connolly using slingshot.co.nz> wrote:
|> > 

[...]

|> 
|> 
|> Patrick,
|> 
|> Are you explicitly calling postscript() in an R session to create the figure?
|> 
|> If so, see the Details section of ?postscript, which notes the following:
|> 

|> The postscript produced for a single R plot is EPS (Encapsulated
|> PostScript) compatible, and can be included into other documents,
|> e.g., into LaTeX, using \includegraphics{<filename>}. For use in
|> this way you will probably want to use setEPS() to set the defaults
|> as horizontal = FALSE, onefile = FALSE, paper = "special". Note
|> that the bounding box is for the device region: if you find the
|> white space around the plot region excessive, reduce the margins of
|> the figure region via par(mar = ).

|> So essentially:
|> 
|> postscript("YourPlot.eps", width = 6.0, height = 6.0,
|>            horizontal = FALSE, onefile = FALSE, paper = "special")

I failed to understand what the 'onefile' argument was about.  I
thought I needed it to be TRUE because I was making a single plot in a
single file. :-( I knew there was something simple I was missing.  I
would have noticed it if I'd read that Details section properly.

|> 
|> Plot code here...
|> 
|> dev.off()
|> 
|> 
|> 

|> Note that instead of pdflatex, you can also use latex, followed by
|> dvips and then ps2pdf, if you want to go that way with the CLI
|> workflow. Might depend upon whether or not you use other PS
|> specific markup in the .tex file, like pstricks. For example:

I used to have a little shell script that did the dvips and ps2pdf but
I recently found that pdflatex seems to do that anyway, so I thought
that was easier and more transportable.

Thanks, Marc.

|> latex YourTeXFile.tex
|> dvips YourTeXFile -o YourTexFile.ps
|> ps2pdf YourTeXFile.ps YourTeXFile.pdf
|> 
|> 
|> Regards,
|> 
|> Marc Schwartz
|> 

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list