[R] autoscaling plot font size in Sweave output possible?

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Jan 7 09:16:09 CET 2005


Patrick Drechsler wrote:

> Hi,
> 
> I was wondering if it's possible to have fonts in plots to be
> autoscaled to the same font size used by LaTeX in a surrounding
> Sweave document.


See ?strwidth which might help for the required calculations.

Uwe Ligges


> Here's a short example in which the fonts of the first plot are
> barely readable:
> 
> --8<------------------------schnipp------------------------->8---
> \documentclass{article}
> \usepackage{graphicx}
> 
> \newcommand{\mytext}{Some normal sized text. Some normal sized
>   text. Some normal sized text. Some normal sized text.}
> 
> \begin{document}
> \SweaveOpts{prefix.string=pics/miniexample}
> 
> \mytext\par
> 
> %% small plot:
> \setkeys{Gin}{width=.45\linewidth}
> @ 
> <<test0,echo=F,fig=T>>=
> x <- 1:10
> y <- sin(x)
> plot(x,y,
>      xlab="some x label",
>      ylab="some y label"
>      )
> @ %def 
> 
> \par\mytext \mytext 
> 
> %% normal sized plot:
> \setkeys{Gin}{width=.9\linewidth}
> @ 
> <<test1,echo=F,fig=T>>=
> plot(x,y,
>      xlab="some x label",
>      ylab="some y label"
>      )
> @ %def 
> 
> \par\mytext
> 
> \end{document}
> --8<------------------------schnapp------------------------->8---
> 
> Do I have to tweak the font size manually (as dicussed f.ex. in
> [1] a while back) or is there a more general way to avoid this
> problem?
> 
> Thankful for any pointers,
> 
> Patrick
> 
> ,----[ R version: ]
> | platform i686-pc-linux-gnu
> | arch     i686             
> | os       linux-gnu        
> | system   i686, linux-gnu  
> | status                    
> | major    2                
> | minor    0.0              
> | year     2004             
> | month    10               
> | day      04               
> | language R    
> `----
> 
> 
> Footnotes: 
> [1] <URL:http://thread.gmane.org/gmane.comp.lang.r.general/20304>
>




More information about the R-help mailing list