2016-04-22 12 views
2

で伝説のフォントを調整します。私はcex =を使用してボックスを調整しようとしましたが、ボックス全体のサイズのみを調整できますが、テキストフォントとは関係ありません。は、私は、テキストがプロットボックス向こうにある</p> <p><a href="https://i.stack.imgur.com/3nUuy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3nUuy.png" alt="Legend of a plot"></a></p> <p>の下に表示凡例を生成するために<code>legend()</code>を使っR

テキストフォントを小さくするにはどうすればよいですか?ここで

は私のサンプルコードです:

legend("bottomleft", legend = c("Simulated", "Estimated/Predicted  
     Median", "95% Credit Intervals"), 
     col = c("gray35", "red", "red"), lty = c(1, 1, 2), 
       lwd = c(3, 2, 1), 
     text.font = 3, inset=.02, bg='gray90') 
+1

これは、グラフィックスデバイスの作成方法によって異なります。しかし、あなたは 'text.width'引数でボックスを拡張することができます – rawr

答えて

1

par()を適用すると、グラフィックパラメータを設定できます。例:

plot(c(1:4), c(1:4), type = 'l')  
par(cex = 1) #set legend font to 1 
legend("topleft", legend="a line", lty = 1) 
0

あなたがbty="n"を設定した場合、それはボックス

legend("bottomleft", legend = c("Simulated", "Estimated/Predicted  
    Median", "95% Credit Intervals"), 
    col = c("gray35", "red", "red"), lty = c(1, 1, 2), 
    lwd = c(3, 2, 1), 
    text.font = 3, inset=.02, bg='gray90',bty="n") 
+0

はい、しかしそれらの間の行間は狭く見えます。私はまだそれらを調整したいと思います。好きなものを小さくし、それらの間のスペースを大きくする。 –

0

を描画しませんcexに異なる値をしようとしているときに、1にpt.cexパラメータを保持するようにしてください凡例の中でpt.cexは、凡例の点と線のサイズを制御します。

x <- rnorm(100, 10, 4) 
y <- rnorm(100, 10, 4) 
plot(x, y, type = "n") 

## I tried to feed cex with 1.1 and 0.4. The font size changes while the lines remain unchanged. 

legend("bottomleft", legend = c("Simulated", "Estimated/Predicted  
    Median", "95% Credit Intervals"), 
    col = c("gray35", "red", "red"), lty = c(1, 1, 2), 
    lwd = c(3, 2, 1), 
    text.font = 3, inset=.02, bg='gray90', pt.cex = 1, cex = 0.4) 

enter image description here

ラインはほぼ同じままで、あなたは、フォントの変更のサイズの大きさを見ることができるように。あなたのプロットに正しい比率が見つからなくなるまで、試してみてください。

関連する問題

 関連する問題