简体   繁体   中英

How to use italics in R graph axis labels

I'm wondering if anyone can help me. I have plotted the following graph:

visreg(MOD.1, xlab="Distance (m)", ylab="Sciurus vulgaris (Presence/Absence)",
       xvar="Distance")

And I would like to make just 'Sciurus vulgaris' in italics. Can anyone help?

Thank you!

Using the example from the documentation of ?visreg I think the functions expression and italic will give you what you need:

fit <- lm(Ozone ~ Solar.R + Wind + Temp,data=airquality)
visreg(fit, xlab="Distance (m)", 
       ylab=expression(italic("Sciurus vulgaris  ") (Presence/Absence)))

Output:

As you can see the y-axis label (only the "sciurus vulgaris") is in italics

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM