在Rmarkdown编织器输出中指定ggplot图的高度和宽度 [英] Specify height and width of ggplot graph in Rmarkdown knitr output

查看:113
本文介绍了在Rmarkdown编织器输出中指定ggplot图的高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用ggplot2创建了一个图,除非该图大于默认值,否则x轴标签不可读.在Rstudio中查看时,我可以动态调整大小.使用ggsave()保存时,我可以指定高度和宽度.如何在Rmarkdown文件中执行此操作,以使输出包含所需大小的图?

I have created a plot with ggplot2 where the x-axis labels are not readable unless the plot is larger than default. When viewing in Rstudio I am able to resize dynamically. When saving with ggsave() I am able to specify height and width. How would I do this within the Rmarkdown file so that the output contains a plot of the desired size?

推荐答案

您可以在代码块中指定高度和宽度

You can specify height and width in the code chunks

```{r, fig.width=10,fig.height=11}
df %>% ggplot(aes(x = x, y = y)) + geom_point()
```

这篇关于在Rmarkdown编织器输出中指定ggplot图的高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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