Knitr中的Cairo字体大小 [英] Cairo font size in Knitr
本文介绍了Knitr中的Cairo字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Cairo设备中设置字体大小,但是pointsize
参数似乎设置了图中点的大小,而不是字体大小.我有这个MWE:
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
具有大的点和普通文本,而fig2
具有相同的文本但小点.
fig1
has large points and normal text, and fig2
has identical text but tiny points.
推荐答案
在R基本图形中,字体大小通常是通过参数cex(.something)
设置的.在这种情况下,您可以使用legend()
函数的cex
参数,例如
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)
这篇关于Knitr中的Cairo字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文