使用R Markdown增加KnitR中轴标签的大小 [英] Increasing the size of axis labels in KnitR with R Markdown

查看:90
本文介绍了使用R Markdown增加KnitR中轴标签的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在带有R Markdown的KnitR中,我可以使用dev.args=list(pointsize=18)pointsize参数传递给图形设备.

In KnitR with R Markdown, I can use dev.args=list(pointsize=18) to pass the pointsize argument to the graphics device.

这会增加图形中点的大小以及图形周围的空间量,但似乎并不会影响轴标签的大小.似乎我也需要使用par(cex.axis=1.5, cex.lab=1.5)之类的东西.

That increases the size of the points in the plot, and also the amount of space around the plot, but it doesn't seem to affect the size of the axis labels. It seems like I need to use something like par(cex.axis=1.5, cex.lab=1.5), too.

这符合预期吗?

以下是三个示例代码块以及生成的图像:

Here are three example code chunks with the images produced:

首先使用默认值:

```{r fig1}
x <- rnorm(100)
y <- 2*x + rnorm(100)
plot(x,y)
```

现在使用dev.args=list(pointsize=18)

```{r fig2, dev.args=list(pointsize=18)}
x <- rnorm(100)
y <- 2*x + rnorm(100)
plot(x,y)
```

现在也使用par(cex.axis=1.5, cex.lab=1.5)

```{r fig3, dev.args=list(pointsize=18)}
par(cex.axis=1.5, cex.lab=1.5)
x <- rnorm(100)
y <- 2*x + rnorm(100)
plot(x,y)
```

推荐答案

您可以考虑使用矢量图形而不是栅格图形,而不是无休止地使用par(cex.blah).例如,您可以使用SVG设备,并在不损失质量的情况下缩放绘图.

Instead of messing with par(cex.blah) endlessly, you can consider vector graphics instead of raster graphics. For example, you can use the SVG device, and scale the plot without quality loss.

```{r fig4, dev='svg', fig.width=6, fig.height=6, out.width='600px'}
x <- rnorm(100)
y <- 2*x + rnorm(100)
par(mar = c(4, 4, .1, .1))
plot(x,y)
```


更新:对于使用png设备的原始问题,未将pointsize参数传递给记录设备.我已经已解决


Update: for the original problem using the png device, the pointsize argument was not passed to the recording device. I have fixed the problem in the development version (>= v1.5.22).

这篇关于使用R Markdown增加KnitR中轴标签的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆