How to Use Italic text in R With Examples

How to Use Italic text in R, To create an italic typeface in R plots, use the following basic syntax.

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

How to Use Italic text in R

The examples below demonstrate how to utilize this syntax in practice.

Example 1: Plot title in italic font

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

Let’s create a data set.

x <- c(1, 3, 2, 4.5, 4, 6, 6, 7, 7, 10)
y <- c(18, 18, 9, 10, 13, 22, 20, 17, 15, 13)

construct a scatterplot with an italicized title

plot(x, y, main = substitute(paste(italic('Scatterplot of x vs. y'))))

the italic font in the title of the plot in R

Make a scatterplot with only some of the titles italicized.

plot(x, y, main = substitute(paste(italic('Scatterplot of'), ' x vs. y')))

It’s worth noting that we can make only part of the words in the title italic:

Example 2: Plot Axis Labels in Italic Font

The following code demonstrates how to make a plot’s x-axis and y-axis labels italic:

We can use the same data set.

x <- c(1, 3, 2, 4.5, 4, 6, 6, 7, 7, 10)
y <- c(18, 18, 9, 10, 13, 22, 20, 17, 15, 13)

make a scatterplot with italicized axes labels.

Handling missing values in R Programming » finnstats

plot(x, y, xlab = substitute(paste(italic('X Axis Label'))),
           ylab = substitute(paste(italic('Y Axis Label'))))

Cool, it’s working.

Example 3: Text in Italic Font in a Plot

The following code demonstrates how to use the italic font in a plot text element:

Let’s make use of the same data set again,

x <- c(1, 3, 2, 4.5, 4, 6, 6, 7, 7, 10)
y <- c(18, 18, 9, 10, 13, 22, 20, 17, 15, 13)

Now we can create a scatterplot

plot(x, y)

at x=4, y=15, insert italic text

text(4, 15, substitute(paste(italic('This is cool magic'))))

You may also like...

Leave a Reply

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

eighteen + 2 =

finnstats