Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 339
R Beginner Avatar asked Dec 10 '15 23:12

R Beginner


People also ask

How do I italicize in R plot?

To write text in italic font, use a single underscore or asterix before and after the text. To write text in bold font, use a double asterix or underscores before and after the text.

How do I customize axis labels in R?

Key ggplot2 R functionsp + xlab(“New X axis label”): Change the X axis label. p + ylab(“New Y axis label”): Change the Y axis label. p + labs(x = “New X axis label”, y = “New Y axis label”): Change both x and y axis labels.

Does R need to be italicized?

Variables are italicized. Superscript numbers are not italicized (e.g., R2). Identifiers (which can be superscript or subscript words, letters, or numbers) are not italicized.

How do you set the axis labels and title of the R plots?

Change main title and axis labelsmain: the text for the main title. xlab: the text for the x axis label. ylab: the text for y axis title. sub: sub-title; It's placed at the bottom of x-axis.


1 Answers

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

enter image description here

like image 192
LyzandeR Avatar answered Nov 01 '22 15:11

LyzandeR