2017-04-03 10 views
1

Rmarkdown文書で図形の幅を調整しようとしています。つまり、ページの幅に収まるように、または少なくともすべてのラベルに収まるように幅を広げています。Rmarkdownで図形の余白を調整する

私はすべて試してみました - par(mar)par(oma)figure.heightfigure.width、余白を調整しますが、何も動作していないようにみえます。パイ自体のサイズが小さくなったり、ラベルがさらに切れたりします。私はパイをできるだけ大きく見えるようにしたいと思っていますが、小さなパイや小さなラベルを描くたびに目立つラベルが付いています。

ラベルが切り取られないように回避策がありますか(または隣接するグラフと重複する可能性があります)?任意の提案をいただければ幸いです。

```{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")) 

enter image description here

+0

使用しているRmdの全体を渡すことはできますか?どの出力形式を使用していますか? –

答えて

1

あなたはチャンクオプション 'out.width' を使用してみてください。ここに私が使用したRmdファイルがあります。私はそれがあなたが望むことをすると思います。

--- 
    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")) 
    ``` 
1

Figureのサイズは、out.widthを指定しない限り、ドキュメントの余白によって制限されます。 Figureの幅がページの余白より大きい場合、R Markdown/knitrは指定された縦横比の図形を作成しますが、余白に収まるように縮小します。

これを解決するには、out.widthを使用してPDFのプロットの幅と高さを設定します。次のようなものがあります。

```{r, fig.align = "center", fig.height = 8, fig.width = 8, 
    out.width = "8.5in"} 

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")) 
```` 

詳細については、this page on knitr chunk optionsを参照してください。

関連する問題