How to increase font size in a plot in R?

前端 未结 7 1413
小鲜肉
小鲜肉 2020-11-28 01:21

I am confused. What is the right way to increase font size of text in the title, labels and other places of a plot?

For example

x <- rnorm(100)
h         


        
7条回答
  •  甜味超标
    2020-11-28 01:58

    By trial and error, I've determined the following is required to set font size:

    1. cex doesn't work in hist(). Use cex.axis for the numbers on the axes, cex.lab for the labels.
    2. cex doesn't work in axis() either. Use cex.axis for the numbers on the axes.
    3. In place of setting labels using hist(), you can set them using mtext(). You can set the font size using cex, but using a value of 1 actually sets the font to 1.5 times the default!!! You need to use cex=2/3 to get the default font size. At the very least, this is the case under R 3.0.2 for Mac OS X, using PDF output.
    4. You can change the default font size for PDF output using pointsize in pdf().

    I suppose it would be far too logical to expect R to (a) actually do what its documentation says it should do, (b) behave in an expected fashion.

提交回复
热议问题