Cairo font size in Knitr

主宰稳场 提交于 2019-12-10 21:02:51

问题


I am trying to set the font size in a Cairo device, but the pointsize argument seems to set the size of the points in the plot, and not the font size. I have this MWE:

\documentclass{article}
\begin{document}
<<setup>>=
library(maptools)
data(meuse)
coordinates(meuse) <- c("x", "y")
proj4string(meuse) <- CRS("+init=epsg:28992")
@

<<fig1, dev='cairo_pdf', dev.args=list(family ="CMU Serif", pointsize=12), fig.keep='last'>>=
plot(meuse, pch=16)
legend("topleft", "Example Text")
@
<<fig2, dev='cairo_png',fig.ext='png',dev.args=list(family ="CMU Serif", pointsize=2), fig.keep='last'>>=
plot(meuse, pch=16)
legend("topleft", "Example Text")
@
\end{document}

fig1 has large points and normal text, and fig2 has identical text but tiny points.


回答1:


In R base graphics, the font size is usually set via the argument cex(.something). In this specific case, you can use the cex argument of the legend() function, e.g.

plot(meuse, pch=16)
legend("topleft", "Example Text", cex=2)


来源:https://stackoverflow.com/questions/16880627/cairo-font-size-in-knitr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!