Set fonts size in R plot

You probably have discovered that R usually gives you different size of fonts in different figures. That is because a numerical value (cex in par function) giving the amount by which plotting text and symbols is magnified relative to a default value. This starts as ‘1’ when a device is opened, and is reset when the layout is changed, e.g. by setting ‘mfrow’.

But the final fonts size for the main title (or axis, lab, sub) is determined by the product of the three variables, ps, cex, and cex.main (or cex.axis, cex.lab, cex.sub), respectively.

So if you want 12 points fonts in the title, you may set the following options

par(ps = 12, cex = 1, cex.main = 1)

Update: it is also possible to have different fonts in axes and title, use cex.main, cex.lab, cex.sub to change the magnification, respectively.


Comments

8 responses to “Set fonts size in R plot”

  1. Cristina Avatar
    Cristina

    Thanks! I was going crazy trying to fit my hclust text!

  2. Saima Shikesho Avatar
    Saima Shikesho

    Hi Thank you for information

    could with how to changing the axis text (8points) and axis labels (9 points) to different font size font size?

    1. Try cex.main, cex.lab, and cex.sub.

  3. Jiayi Avatar
    Jiayi

    Thank you so much!

  4. Sheraz Mirza Avatar
    Sheraz Mirza

    Thanks for sharing

  5. Excellent
    Thank you!!!!!

  6. Erin Avatar
    Erin

    Thanks a lot!

  7. Thanks! Just what I needed.

Leave a Reply

Your email address will not be published. Required fields are marked *