I use legend() to produce a legend shown below

The text lies beyond the plot box. I tried to use cex = to adjust the box, however, it can only adjust the size of the whole box, but have nothing to do with the text font.
Is there anyway to make the text font smaller?
Here is my sample code:
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')
You can set graphical parameters by applying par(). For example:
plot(c(1:4), c(1:4), type = 'l')
par(cex = 1) #set legend font to 1
legend("topleft", legend="a line", lty = 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With