How to Use Bold Font in R with Examples

[This article was first published on Data Science Tutorials, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The post How to Use Bold Font in R with Examples appeared first on Data Science Tutorials

What do you have to lose?. Check out Data Science tutorials here Data Science Tutorials.

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)

The post How to Use Bold Font in R with Examples appeared first on Data Science Tutorials

Learn how to expert in the Data Science field with Data Science Tutorials.

To leave a comment for the author, please follow the link and comment on their blog: Data Science Tutorials.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)