r - How to specify font sizes in plots with multiple plots per page? -
when generate .pdf file using knitr within rstudio, single plots exhibit desired font sizes of axis labels, legend, etc. however, when use layout() function generate multiple sub-plots, these font sizes reduced. please see example code below.
\documentclass[12pt,english,twocolumn]{article} \begin{document} <<settings, message=false, echo=false, cache=false>>= # set tikz default options opts_chunk$set( out.width='15cm', fig.width=5.906, # inch fig.height=5.906, # inch dev='tikz', fig.align='center', fig.lp='fig:', fig.env='figure*', dev.args=list(pointsize=10), message=false, echo=false ) options(tikzdefaultengine = "pdftex") @ <<singleplot, fig.cap="single plot font size">>= par(cex=1) plot(rnorm(100)) @ <<multipleplots, fig.cap="multiple plots fonts being small">>= par(cex=1) layout(matrix(1:9, 3)) for(i in 1:9) plot(rnorm(100)) @ \end{document}
how fonts in second plot of same size ones in first plot? thanks!
oh my, figured out myself 30 seconds after posting question...
the trick reverse order of layout() , par() in second plot, so:
<<multipleplots, fig.cap="multiple plots fonts being right">>= layout(matrix(1:9, 3)) par(cex=1) for(i in 1:9) plot(rnorm(100)) @
this works expected.
so seems layout() calls par() internally set new (smaller) character expansion value when setting multiple plots. setting par(cex=1) before layout had no effect. had not known this, makes sense. sorry unneccessary disturbance.
Comments
Post a Comment