How to Use Bold Font in R with Examples

How to Use Bold Font in R, to create a bold typeface in R plots, use the basic syntax shown below:

substitute(paste(bold('datasciencetut.com')))

These examples demonstrate how to apply this syntax in real-world situations.

Example 1: Plot’s axis labels in bold font

The code below demonstrates how to make a scatter plot in R with both axis labels in regular font:

How to Use Bold Font in R, First define data

x <- c(1, 2, 3, 4, 4, 5, 6, 6, 7, 9)
y <- c(38, 58, 55, 60, 65, 52, 40, 45, 34, 57)

To make a scatter plot with axis labels in regular font.

plot(x, y, xlab='X Label', ylab='Y Label')

Additionally, the code below demonstrates how to set bold font for a plot’s x-axis and y-axis labels:

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

The labels for both axes are now bold, as you can see.

Example 2: Bold Font with Text in Plot

Let’s add normal text at location x=3, y=54

text(3, 54, 'datasciencetut.com')

Now we can add bold text at location x=6, y=64

text(6, 64, substitute(paste(bold('datasciencetut.com'))))

Take note of how the bold font differs from the regular type.

Further Resources:-
The following tutorials provide guidance on using R to learn:

Change ggplot2 Theme Color in R- Data Science Tutorials

Best GGPlot Themes You Should Know – Data Science Tutorials

How to Label Outliers in Boxplots in ggplot2? (datasciencetut.com)

You may also like...

Leave a Reply

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

4 × 2 =