调整Rmarkdown中的图形边距 [英] Adjusting figure margins in Rmarkdown

查看:486
本文介绍了调整Rmarkdown中的图形边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调整Rmarkdown文档中的饼形图,使其覆盖页面的宽度,或者至少变得足够宽以适合所有标签.

I am trying to adjust the piechart figure in my Rmarkdown document so that it spans the width of the page or at least becomes wide enough to fit all of the labels.

我已经尝试了所有方法-调整figure.heightfigure.width,用par(mar)par(oma)设置边距,但是似乎没有任何效果.要么馅饼本身变得更小,要么标签被切除得更多.我希望带有清晰可见标签的饼尽可能大,但是每次它呈现小馅饼和小标签时.

I have tried everything - adjusting figure.height and figure.width, margins with par(mar) and par(oma), but nothing seems to work. Either the pies themselves become smaller, or the labels are even more cut off. I would like the pies to be as large as possible with clearly visible labels, but every time it renders small pies and tiny labels.

是否至少有一种解决方法,以使标签不被切除(或可以与相邻图表重叠)?任何建议,将不胜感激.

Is there a workaround at least so that labels are not cut off (or can overlap the adjacent chart)? Any suggestions would be appreciated.

```{r, figure.align = "center", figure.height = 10, figure.width = 12}

par(mfrow=c(1,3), cex.axis=1.5, cex.lab=1.5) 
par(mar = c(4,2,4,2))
par(oma = c(3, 3, 3, 3))
pie(a, labels = lbls,  font = 2, col = c("tomato", "white"), cex=2)
pie(b, lbls2, font = 2, col = c("tomato", "white"), cex=2) 
mtext(side=3, text="Plan Breakdown: Top 20% of Users")
pie(c, lbls3,  font = 2, col = c("tomato", "white"))

推荐答案

您可以尝试使用块选项'out.width'.这是我使用的Rmd文件.我认为它可以满足您的要求.

You might try using the chunk option 'out.width'. Here is the Rmd file that I used. I think that it does what you want.

    ---
    output: pdf_document
    ---


    ```{r, out.width='\\textwidth', fig.height = 8, fig.align='center'}
    pie(c(0.57, 0.43), font = 2, col = c("tomato", "white"))

    pie(c(0.57, 0.43), font = 2, col = c("blue", "orange"))
    ```

这篇关于调整Rmarkdown中的图形边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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