Skip to content

Data Science Tutorials

For Data Science Learners

  • Data Science Challenges in R Programming Language
    Data Science Challenges in R Programming Language Machine Learning
  • How to get the last value of each group in R
    How to get the last value of each group in R R
  • Group By Maximum in R
    Group By Maximum in R R
  • Select variables of data frame in R R
  • How to change the column positions in R?
    How to change the column positions in R? R
  • How Do Online Criminals Acquire Sensitive Data
    How Do Online Criminals Acquire Sensitive Data Machine Learning
  • How to Use Gather Function in R
    How to Use Gather Function in R?-tidyr Part2 R
  • R Percentage by Group Calculation
    R Percentage by Group Calculation R
Changing the Font Size in Base R Plots

Changing the Font Size in Base R Plots

Posted on September 25September 23 By Admin No Comments on Changing the Font Size in Base R Plots

Changing the Font Size in Base R Plots, To alter the font size of different elements in base R charts, use the syntax shown below:

plot(df$x, df$y, main='Title', sub='Subtitle',
     cex.main=2, #change font size of title
     cex.sub=2, #change font size of subtitle
     cex.lab=2, #change font size of axis labels
     cex.axis=2) #change font size of axis text  

The scatterplot shown below in base R can be used with this syntax by using the examples that follow:

Make a data frame

df <- data.frame(x=c(1, 2, 3, 4, 5, 6),
y=c(54, 81, 22, 36, 45, 63))
df
x  y
1 1 54
2 2 81
3 3 22
4 4 36
5 5 45
6 6 63

Create a scatterplot using the standard font sizes.

plot(df$x, df$y, main='Title', sub='Subtitle')

Example 1: Change Font Size of Title

The story title’s font size can be altered using the code below:

build a scatterplot with the title’s font size raised

plot(df$x, df$y, main='Title', sub='Subtitle', cex.main=2)

Example 2: Change Font Size of Subtitle

The plot’s subtitle can be changed by using the code provided below:

generate a scatterplot with the subtitle’s text size raised

plot(df$x, df$y, main='Title', sub='Subtitle', cex.sub=2)

Example 3: Change Font Size of Axis Labels

The plot’s axis labels’ font size can be altered using the code below:

generate a scatterplot with axis labels in larger font sizes.

plot(df$x, df$y, main='Title', sub='Subtitle',     cex.lab=2)

Example 4: Change Font Size of Axis Text

The plot’s axis text’s font size can be altered using the code below:

generate a scatterplot with the axis text’s font size raised.

plot(df$x, df$y, main='Title', sub='Subtitle', cex.axis=2)

Check your inbox or spam folder to confirm your subscription.

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

How to Add a caption to ggplot2 Plots in R? (datasciencetut.com)

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

How to add labels at the end of each line in ggplot2? (datasciencetut.com)

R

Post navigation

Previous Post: Gamma distribution in R
Next Post: How to Use Bold Font in R with Examples

Related Posts

  • Hypothesis Testing in R Programming
    Hypothesis Testing in R Programming R
  • Separate a data frame column into multiple columns
    Separate a data frame column into multiple columns-tidyr Part3 R
  • How to Count Distinct Values in R
    How to Count Distinct Values in R R
  • Using describeBy() in R: A Comprehensive Guide R
  • How to Find the Size of a Data Frame in R R
  • How to compare variances in R
    How to compare variances in R R

Leave a Reply Cancel reply

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

  • Best Prompt Engineering Books
  • Understanding Machine Learning and Data Science
  • Best Git Books
  • Top 5 Books to Learn Data Engineering
  • Mastering R Programming for Data Science: Tips and Tricks
  • About Us
  • Contact
  • Disclaimer
  • Privacy Policy

https://www.r-bloggers.com

  • YouTube
  • Twitter
  • Facebook
  • Course
  • Excel
  • Machine Learning
  • Opensesame
  • R
  • Statistics

Check your inbox or spam folder to confirm your subscription.

  • How to Visualize PCA Results in R
    How to Visualize PCA Results in R R
  • Algorithm Classifications in Machine Learning
    Algorithm Classifications in Machine Learning Machine Learning
  • 5 Free Books to Learn Statistics For Data Science
    5 Free Books to Learn Statistics For Data Science Course
  • What is the best way to filter by row number in R?
    What is the best way to filter by row number in R? R
  • Is Data Science a Dying Profession
    Is Data Science a Dying Profession? R
  • How to Implement the Sklearn Predict Approach
    How to Implement the Sklearn Predict Approach? R
  • How to create contingency tables in R
    How to create contingency tables in R? R
  • Add Significance Level and Stars to Plot in R
    Add Significance Level and Stars to Plot in R R

Privacy Policy

Copyright © 2025 Data Science Tutorials.

Powered by PressBook News WordPress theme