Home » How to Use Italic Font in R (With Examples)

How to Use Italic Font in R (With Examples)

by Tutor Aspire

You can use the following basic syntax to produce italic font in R plots:

substitute(paste(italic('this text is italic')))

The following examples show how to use this syntax in practice.

Example 1: Italic Font in Title of Plot

The following code shows how to use italic font in the title of a plot in R:

#define data
x #create scatterplot with title in italics
plot(x, y, main = substitute(paste(italic('Scatterplot of x vs. y'))))

italic font in title of plot in R

Note that we can also specify italic font for only some of the words in the title:

#create scatterplot with only some of title in italics
plot(x, y, main = substitute(paste(italic('Scatterplot of'), ' x vs. y')))

Example 2: Italic Font on Axis Labels of Plot

The following code shows how to specify italic font for the x-axis and y-axis labels of a plot:

#define data
x #create scatterplot with axes labels in italics
plot(x, y, xlab = substitute(paste(italic('X Label'))),
           ylab = substitute(paste(italic('Y Label'))))

Example 3: Italic Font with Text in Plot

The following code shows how to include italic font for a text element inside of a plot:

#define data
x #create scatterplot
plot(x, y)

#add italic text at location x=3, y=16
text(3, 16, substitute(paste(italic('This is some italic text'))))

Additional Resources

The following tutorials explain how to perform other common functions in R:

How to Add Superscripts & Subscripts to Plots in R
How to Change Font Size in ggplot2

You may also like